Skip to content

tuyetrinhvo/mybilemo

Repository files navigation

mybilemo

SensioLabsInsight Codacy Badge

Create an API with Symfony.

Installation

Use the command :

php bin/console doctrine:database:create

php bin/console doctrine:schema:update --force

php bin/console doctrine:fixtures:load

php bin/console fos:user:create

php bin/console create:new:client

php bin/console server:run

Tests with Postman :

Get New Access token in Postman :

Make POST request with '127.0.0.1:8000/oauth/v2/token'

(or 'bilemo.ttvo.fr/oauth/v2/token')

On the 'body tab', check 'raw', 'JSON' and inquire:

{
  "grant_type": "password",
  "client_id": "YourClientId",
  "client_secret": "YourCLientSecret",
  "username": "YourUsername",
  "password": "YourPassword"
}

You will receive an access token and a refresh token.

Your access token expires after one hour !


Connect to the Api with this access token

1.Get products's list : Make GET request with '127.0.0.1:8000/products'

On the 'authorization', choose 'Bearer token', and copy-paste the access token.

2.Show a product : Make GET request with '127.0.0.1:8000/products/{id}'

3.Create a new user : Make POST request with '127.0.0.1:8000/users'

On the 'body tab', check 'raw', 'JSON' and inquire:
{
   "username": "YourUsername",
   "email": "YourEmail",
   "password": "YourPassword"
}

4.Get user's list : Make GET request with '127.0.0.1:8000/users'

5.Show a user : Make GET request with '127.0.0.1:8000/users/{id}'

6.Delete a user : Make DELETE request with '127.0.0.1:8000/users/{id}'


Use the refresh token

Make POST request with '127.0.0.1:8000/oauth/v2/token'

(or 'bilemo.ttvo.fr/oauth/v2/token')

On the 'body tab', check 'raw', 'JSON' and inquire:

{
   "grant_type": "refresh_token",
   "client_id": "YourClientId",
   "client_secret": "YourClientSecret",
   "refresh_token": "YourRefreshToken"
}

Documentation

You will find the documentation at '127.0.0.1:8000/api/doc'

(or 'bilemo.ttvo.fr/api/doc')

TuyetrinhVO

About

Create an API with Symfony

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published