zajca/symfony-extensions

Variety extensions for symfony.

dev-main 2021-10-12 13:48 UTC

This package is auto-updated.

Last update: 2024-04-12 19:18:22 UTC


README

This library contains a variety of extensions to ease work with Symfony framework

Install

Use composer to install the lib from packagist.

composer require zajca/symfony-extensions

Usage

Exception

Basic exception handling for http kernel.

Two Exception exists extending Exception interface: Zajca\Extensions\Exception\ExceptionInterface

  • Zajca\Extensions\Exception\InternalException - Exception which will return 500 status code but will log more information than standard Exception
  • Zajca\Extensions\Exception\PublicException - Exception which will be serialized and shown to api consumer

Usage in symfony

Register exception listener and use/extend predefined exceptions

services:
    Zajca\Extensions\Exception\ExceptionListener:
        tags:
            - { name: kernel.event_listener, event: kernel.exception }

Request mapping

Argument value resolver more in symfony docs which will map user input from request to object.

Examples

For examples check the tests: Zajca\Extensions\Tests\RequestMapping\ArgumentValueResolver\Example\ControllerStub

Route

Environment