Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.07 KB

README.md

File metadata and controls

66 lines (47 loc) · 1.07 KB

API

Add simple API to Symfony projects

Install

Instal the bundle

comoser require osw3/symfony-api

Prepare for update

In your composer.json file, change the line of the dependency to prepare futures updates of the bundle.

"osw3/symfony-api": "*",

Enable the bundle

Add the bundle in the config/bundle.php file.

return [
    OSW3\Api\ApiBundle::class => ['all' => true],
];

Usage

Enable the router

Add the bundle route to the config/routes.yaml file.

_api:
    resource: '@ApiBundle/Resources/config/routes.yaml'

Configure the bundle

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']