Add simple API to Symfony projects
comoser require osw3/symfony-api
In your composer.json file, change the line of the dependency to prepare futures updates of the bundle.
"osw3/symfony-api": "*",
Add the bundle in the config/bundle.php
file.
return [
OSW3\Api\ApiBundle::class => ['all' => true],
];
Add the bundle route to the config/routes.yaml
file.
_api:
resource: '@ApiBundle/Resources/config/routes.yaml'
api:
my_api_v1:
version: 1
collections:
all_books:
class: App\Entity\Book
privileges:
public:
granted: null #'PUBLIC_ACCESS'
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']