composer require vankosoft/api-bundle
<?php
return [
---
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Vankosoft\ApiBundle\VSApiBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
---
];
imports:
- { resource: "@VSApiBundle/Resources/config/app/api_platform.yaml" }
- { resource: "@VSApiBundle/Resources/config/app/serializer.yaml" }
- { resource: "@VSApiBundle/Resources/config/app/lexik_jwt_authentication.yaml" }
- { resource: "@VSApiBundle/Resources/config/app/nelmio_cors.yaml" }
vs_api:
enabled: true
vs_api_platform:
resource: "@VSApiBundle/Resources/config/routing/api_platform.yaml"
prefix: /
vs_api_users:
resource: "@VSApiBundle/Resources/config/routing/api.yaml"
prefix: /
vs_api_test_index:
path: /api/test-index
controller: App\Controller\Api\TestController::index
bin/console lexik:jwt:generate-keypair
The keys will be generated in <project_dir>/config/jwt/
{
"username":"admin",
"password":"admin"
}
The returned response is something like:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2NjY4NzkxOTcsImV4cCI6MTY2Njg4Mjc5Nywicm9sZXMiOlsiUk9MRV9TVVBFUl9BRE1JTiJdLCJ1c2VybmFtZSI6ImFkbWluIn0.Iu6tRGdXD4PfG08t62TK_oW32lfUd2MPzZ6ygpD7q5me7qvqnjGosU9xfI5ygE34LAhk2KWGG7Jgww0h9iL_3nbjMWN3lzhkVBYhZSbs7bXuz914moSz7_eYPJqKrGpklHVKWAXz6ksFaz2TxW34jR2xMEjoYGYmB_4S03CpsbpTBFHvmxfNym_NTy9ye7xDFcPZg3elQHa2J3r0llgnMjenyonFAvoMSHE8d71cyLDLOBci4juGl2P4oLO0ZR2xcw3qVThsVfGxz3VcdTYH730_kvtI5YIwhAViTAzFunvOz5NpURhLFXn9xCkISi5EVisp5SRxhOqFo_CsMIWYrg"
}
{
"status": "ok",
"data": {
"tokenCreatedTimestamp": 1666879197,
"tokenExpiredTimestamp": 1666882797,
"user": {
"username": "admin",
"email": "admin@test-vankosoft-application.lh",
"firstName": "Super",
"lastName": "Admin"
}
}
}