dropelikeit / laravel-jms-serializer
Integration JMS Serializer in Laravel / Lumen
Installs: 1 979
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|^10.0
- illuminate/http: ^9.0|^10.0
- illuminate/support: ^9.0|^10.0
- jms/serializer: ^3.27
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.23
- infection/infection: ^0.27.6
- nunomaduro/larastan: ^2.6
- orchestra/testbench: ^8.9
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.3
- psalm/plugin-laravel: ^2.8
- psalm/plugin-phpunit: ^0.18.4
- roave/security-advisories: dev-latest
- symfony/cache: ^6.3
- vimeo/psalm: ^5.15
This package is auto-updated.
Last update: 2024-04-19 19:37:35 UTC
README
JMS Serializer for Laravel
This package integrates the JMS serializer into Laravel.
JMS-Serializer: https://github.com/schmittjoh/serializer
You are also welcome to use the Issue Tracker to set bugs, improvements or upgrade requests.
Installation
composer require dropelikeit/laravel-jms-serializer
Support note
- Laravel 6 and 7 are no longer supported with release v4.0.0 and higher.
- Laravel 5.* is no longer supported with release v2.0.0 and higher.
How to use
Laravel uses Package Auto-Discovery, so you do not need to add the service provider manually.
For example, to use the JMS serializer in a controller, add the ResponseFactory in the constructor.
<?php namespace App\Http\Controller; use Dropelikeit\LaravelJmsSerializer\Http\Responses\ResponseFactory; use Symfony\Component\HttpFoundation\JsonResponse; final class ExampleController extends Controller { public function __construct(private ResponseFactory $responseFactory) {} public function myAction(): JsonResponse { $myDataObjectWithSerializerAnnotations = new Object('some data'); return $this->responseFactory->create($myDataObjectWithSerializerAnnotations); } }
Publish the Serializer Config with the command
php artisan vendor:publish
After that you will see a config file in your config folder named "laravel-jms-serializer.php".
Upgrade
If you are upgrading this package from a version earlier than v4.0, see this upgrade file.