denisok94/symfony-helper

Symfony helper

Installs: 977

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.0.12 2024-01-30 08:59 UTC

This package is auto-updated.

Last update: 2024-10-30 01:43:04 UTC


README

Installation

Run:

composer require --prefer-dist denisok94/symfony-helper
# or
php composer.phar require --prefer-dist denisok94/symfony-helper

or add to the require section of your composer.json file:

"denisok94/symfony-helper": "*"
composer update
# or
php composer.phar update

Setting

// ~config/bundles.php
return [
    //..
    Denisok94\SymfonyHelper\Denisok94SymfonyHelperBundle::class => ['all' => true],
];

Унаследовать настройки родительского контроллера

# ~config/services.yaml
    # global if all controller extends ApiRestController or ApiListController
    App\Controller\:
        parent: 'denisok94.controller.api_rest_controller'
    # or individual 
    App\Controller\MyController:
        parent: 'denisok94.controller.api_rest_controller'

Возвращать ошибки в формате json

# ~config/packages/framework.yaml
framework:
    error_controller: Denisok94\SymfonyHelper\Controller\JsonErrorController::show

Возвращать ошибки доступа в формате json

# ~config/packages/security.yaml
security:
    firewalls:
        main: # or other name use
            access_denied_handler: Denisok94\SymfonyHelper\Security\AccessDeniedHandler

Use