Laravel 10 – 11
PHP 8.1+
No release in over 2 years
Low commit activity in last 18 months
Integration JMS Serializer in Laravel / Lumen
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

roave/security-advisories
dev-latest
phpunit/phpunit
^10.5
phpstan/phpstan-phpunit
^1.3
php-parallel-lint/php-parallel-lint
^1.3
symfony/cache
^6.3|^7.0
vimeo/psalm
^5.23
psalm/plugin-phpunit
^0.19
^10.0|^v11.0

Runtime

^10.0|^11.0
jms/serializer
^3.30
 Project Readme

Gitworkflow Coverage Status Monthly Downloads Daily Downloads Total Downloads Latest Stable Version Total Downloads License composer.lock Mutation testing badge

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.

Please use the new package https://github.com/Dropelikeit/laravel-responsefactory in the future. The new package contains some new and useful functions! This package will only be supported until the end of Laravel 11. Until then, you should use the new package.

Installation

composer require dropelikeit/laravel-jms-serializer

Support note

Laravel PHP Package Version Status
11 8.2, 8.3 v6.x.x Support
10 8.1, 8.2, 8.3 >=v5.x.x Support
9 8.0, 8.1, 8.2 v4.x.x - v5.1.0 Not supported
8 7.3, 7.4, 8.0, 8.1 v3.x.x - v4.0.0 Not supported
7 7.2, 7.3, 7.4, 8.0 v2.x.x - v3.0.0 Not supported
6 7.2, 7.3, 7.4, 8.0 v1.x.x - v3.0.0 Not supported

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.

Documentation