Skip to content

Cannot install doctrine/dbal with recent Laravel Installations #49403

Closed
@KentarouTakeda

Description

@KentarouTakeda

Laravel Version

10.37.3 / probably all versions

PHP Version

8.3.0 / probably all versions

Database Driver & Version

N/A

Description

Dependency resolution with composer require doctrine/dbal fails in a recently Laravel installation.
(This may not be caused by Laravel itself)

Here is a summary of the failures:

  1. composer create-project laravel/laravel

    • laravel/framework v10.37.3 requires nesbot/carbon (^2.67)
      • resolved to 2.72.1
    • nesbot/carbon 2.72.1 requires carbonphp/carbon-doctrine-types (*)
      • resolved to 3.1.0
  2. composer require doctrine/dbal

    • carbonphp/carbon-doctrine-types 3.1.0 conflicts with doctrine/dbal 3.7.2

Previously this did not occur. This issue now occurs due to the following changes in nesbot/carbon.

briannesbitt/Carbon@4d06802#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34

In short, Laravel applications installed after November 28, 2023, when the above changes were published, will not be able to install doctrine/dbal in the normal way.

For now, the workaround would be:

UPDATED: 2023-12-20 12:09 JST
Fixed since a better procedure was mentioned in the comments.

  1. Manually add { "require": { "doctrine/dbal":"^3.5.1" } } to composer.json.
    Run composer require doctrine/dbal carbonphp/carbon-doctrine-types
  2. Run composer update
    Here carbonphp/carbon-doctrine-types will be DOWNGRADED to 2
  3. Then, doctrine/dbal is installed without any problems.

This is not a problem with Laravel, but given that special installation steps are required and packages may be downgraded during this process, some countermeasures may be necessary.
(But I don't know your package dependency policy, so I don't have any ideas, sorry)

Steps To Reproduce

sh-3.2$ composer create-project laravel/laravel

### omission

> @php artisan key:generate --ansi

   INFO  Application key set successfully.

sh-3.2$ cd laravel
sh-3.2$ php artisan model:show User

 ┌ Inspecting database information requires the Doctrine DBAL (doctrine/dbal) package. Would you like to install it? ┐
 │ Yes                                                                                                               │
 └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

./composer.json has been updated
Running composer update doctrine/dbal
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires doctrine/dbal ^3.5.1 -> satisfiable by doctrine/dbal[3.5.1, ..., 3.7.2].
    - nesbot/carbon 2.72.1 requires carbonphp/carbon-doctrine-types * -> satisfiable by carbonphp/carbon-doctrine-types[3.1.0].
    - laravel/framework v10.37.3 requires nesbot/carbon ^2.67 -> satisfiable by nesbot/carbon[2.72.1].
    - carbonphp/carbon-doctrine-types 3.1.0 conflicts with doctrine/dbal 3.7.2.
    - laravel/framework is locked to version v10.37.3 and an update of this package was not requested.


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions