Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require uni-method/symfony-bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require uni-method/symfony-bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
UniMethod\Bundle\UniMethodBundle::class => ['all' => true],
];
Create if not exist config/packages/uni_method.yaml
uni_method:
default_path: '%kernel.project_dir%/config/jsonapi' # path to entities config
prefix: 'v' # prefix for version forexample /v1/user/
available: # all available versions
- 1 # version (subfolder in default_path)
# config/jsonapi/1/config.yml
entities:
user:
class: 'App\Entity\User'
description: 'Just a user'
attributes:
id:
getter: 'getId()'
type: integer
email:
getter: 'getEmail()'
type: string
paths:
-
item: user
method: list
# config/routes.yaml
app_extra:
resource: .
type: extra