Menu Close
    Hire us Request quote Reading list Switch to dark mode
    lockdownWebkulUp

    How To Install Sylius and Fetch Access Token For API?

    SYLIUS INSTALLATION

    For installing Sylius the following points are necessary :

    1. The PHP version should be 7.2 or higher.
    2. The composer should have been installed.

    Follow the below given points to install Sylius:

    1. To creating your new project, run the following command :
      • $ composer create-project sylius/sylius-standard your_project_name
    2. Move inside your project directory
      • $ cd your_project_name
    3. Now create .env.local file below .env file in the same directory and add/customise with variable you want to override like:
      • DATABASE_URL=mysql://username:password@host/my_custom_sylius_database
    4. Run the following command to install Sylius:
      • $ php bin/console sylius:install
    5. The above command will ask to provide more information and it sets currency as USD and default locale as English – US which can be changed later.
    6. For fully functional front-end run following commands:
      • $ yarn install
      • $ yarn build

    By following above commands you will be able to access your Sylius shop after running the command symfony server:start and accessing http://127.0.0.1:8000 on your web browser.

    How to use Sylius API?

    To use Sylius API, one need to get access token for the same which can be fetched by following steps:

    1. Create OAuth client by running following command:
      • $ php bin/console sylius:oauth-server:create-client –grant-type=”password” –grant-type=”refresh_token” –grant-type=”token”
    2. You will receive a response like : A new client with public id XYZ, secret ABC has been added.

    Now, From your API Client ,

    Register your API end point to get access token:

    Creating a function to get Access Token :

    The above function call 3 major functions:

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .
    1. Creating request for Access Token API.
    2. Default Curl Setting.
    3. Creating response for Access Token API.

    Creating request for Access Token API.

    Default Curl Setting.

    Creating response for Access Token API.

    This will set fetched Access Token into $this->accessToken variable which can be further used to manipulate Sylius Store Data with APIs.

    NOTE – The older version of PHP will result in installing older version of Sylius.

    Thanks for reading me. I hope this blog would help you with a better understanding of the Sylius Installation and getting Access Token. Please share your reviews on this, which will support me to write more.

    Until next time. 👋

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close