Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 1.96 KB

Symfony.md

File metadata and controls

67 lines (53 loc) · 1.96 KB

Symfony integration

I. Dependencies

Melodiia does not provide Symfony dependencies. If you are not using the Symfony full edition (which is recommended) here are the components you're going to need to install.

composer req symfony/form symfony/asset

II. Configure

Add it as bundle. Modify bundles.php file and add the following:

// config/bundles.php
return [
    // Some other bundles already registered here
    // ...
    
    Biig\Melodiia\Bridge\Symfony\MelodiiaBundle::class => ['all' => true],
];

By default it comes with a configuration that will consider / is your API. It's recommended to change it.

melodiia:
    apis:
        main:
            # All those options are used for documentation purpose.
            paths: ['%kernel.project_dir%/src'] # List of path where melodiia will look for documentation blocks
            enable_doc: true
            base_path: /                        # Path to your API
            title: Awesome API                  
            description: |
                This is an awesome API. Really.
            version: 1.0.0
            pagination:
                max_per_page_attribute: 'max_per_page'
        # Melodiia comes with some form extensions, it makes your life easier
        # but in some case this could break some parts of an existing application
        # or just not act like you expect. That's why you can't disable extensions.
        form_extensions:
            # enabled by default, set false to disable.
            datetime: true

III. Override Melodiia services

The below configuration override the default pagination request factory. So Melodiia will execute Your\FQCN\YourClass instead of Biig\Melodiia\Crud\Pagination\PaginationRequestFactory to create PaginationRequest object

#services.yaml

Biig\Melodiia\Crud\Pagination\PaginationRequestFactoryInterface:
    alias: Namespace\To\Your\Class