schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 589 forks source link

The serializer cannot be installed in a Laravel version 10 project. #1482

Closed Dropelikeit closed 1 year ago

Dropelikeit commented 1 year ago
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

PHP: 8.1 JMS/Serializer: 3.23 Laravel: 10

Since the release of Laravel version 10, this library can no longer be installed because it ends in a dependency problem. The reason is that Laravel now uses doctrine/lexer:^3.0.0 and this library can be used with version ^1 or ^2. It should also work with ^3.

Steps required to reproduce the problem

  1. Create a new Laravel 10 project (composer create-project laravel/laravel example-app)
  2. Install via composer this library or dropelikeit/laravel-jms-serializer

Expected Result

Actual Result

 Problem 1
    - Root composer.json requires jms/serializer ^3.23 -> satisfiable by jms/serializer[3.23.0].
    - jms/serializer 3.23.0 requires doctrine/lexer ^1.1 || ^2 -> found doctrine/lexer[1.1.0, ..., 1.2.3, 2.0.0, 2.1.0] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

It should not be necessary to downgrade the doctrine/lexer package to use this library. I don't know what exactly is broken in Laravel when doctrine/lexer is downgraded.

mbabker commented 1 year ago

If you use the --with-all-dependencies flag as the Composer message suggests, unless you've got a package that ONLY supports doctrine/lexer:>=3.0, you should be able to install the serializer and have the lexer package downgraded to 2.x.

Checking a Laravel project I have at work:

$ composer why doctrine/lexer
doctrine/annotations      2.0.1   requires doctrine/lexer (^2 || ^3)     
egulias/email-validator   4.0.1   requires doctrine/lexer (^2.0 || ^3.0) 
friendsofphp/php-cs-fixer v3.16.0 requires doctrine/lexer (^2 || ^3)

So, Laravel itself does NOT depend on the lexer.

Note, because of the lexer package's API redesign, either a combination of 1.x and 2.x or a combination of 2.x and 3.x can be supported, there isn't a sane way to support all 3 major versions.

Dropelikeit commented 1 year ago

Thank you very much for your quick reply. As you correctly described, the installation works with the --with-all-dependencies flag. Nevertheless, I thought I would create this ticket to point out that Laravel 10 no longer supports doctrine-lexer version 1 and the message appears when adding the JMS/Serializer in a newly deployed Laravel app.