Resolving Composer Dependency Conflicts Between Laravel 9 and Passport 10
Attempting to install Laravel Passport version 10 into a project configured for Laravel 9 often triggers an immediate failure during composer require. The error message Your requirements could not be resolved to an installable set of packages appears quickly, but the underlying cause lies in how Composer resolves transitive dependencies and handles package aliases.
The core issue stems from a version mismatch between the main framework and its authentication provider. Laravel Passport 10 explicitly requires illuminate/auth version 8.2 or higher (or 8.0 depending on the specific sub-version). However, your project's root composer.json likely declares laravel/framework:^9.0.
In the Laravel ecosystem, laravel/framework is not just a standard package; it acts as an alias that replaces specific underlying packages like illuminate/support, illuminate/routing, and illuminate/auth. When you require laravel/framework@^9.0, Composer installs the framework bundle, which internally manages these core components at version 9.x.
When you then attempt to add laravel/passport@^10.0, Composer sees a conflict. Passport wants an illuminate/auth compatible with Laravel 8 (specifically versions between 8.0 and 8.x-dev), but your environment already has illuminate/auth locked to version 9.x by the framework alias. You cannot satisfy both constraints simultaneously because they point to incompatible minor versions of the same core library.
The error logs often look confusing, specifically this line:- Only one of these can be installed: illuminate/support[dev-master, v6.0.0, ..., 8.x-dev], laravel/framework[dev-master]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
This confirms that the framework bundle is overriding the standalone illuminate packages. Even if you try to bypass this by running composer require --no-update laravel/passport, subsequent attempts to run composer update will fail because the resolver still detects the incompatibility between the 9.x core and the 8.x Passport requirements.
The Solution: Downgrade to Match the Package Ecosystem
Since Passport 10 is designed for Laravel 8, you must align your framework version with it before installing the package. There is no way to force Passport 10 to work natively with a fresh Laravel 9 installation without significant code refactoring or using a different authentication provider.
To resolve this cleanly:
- Backup and Remove Existing Artifacts: If you are starting a new migration of an existing project, delete the
vendorfolder and thecomposer.lockfile. You must also ensure yourcomposer.jsonreflects the correct Laravel version for Passport 10. - Adjust Framework Version: In your
composer.json, change the requirement from:
to:"laravel/framework": "^9.0"
Alternatively, if you are moving an existing project, you may need to downgrade the framework manually by removing the vendor folder and running"laravel/framework": "^8.x"composer updatewhile temporarily restricting the version constraint. - Install Passport: Once the root framework is aligned with Laravel 8, run:
composer require laravel/passport:^10.0
Composer will now be able to resolve the dependencies correctly, installing illuminate/auth at a version compatible with both the framework and Passport.
Important Considerations for Laravel 8 Ecosystem
Be aware that this approach locks your project into the Laravel 8 ecosystem. Laravel 9 introduced breaking changes (such as dropping support for PHP 7.3) that may not be backward compatible with code written specifically for Laravel 8 or Passport 10. If your goal is to maintain Laravel 9 features, you must consider upgrading Passport to version 11, which aligns with Laravel 9's dependency requirements, provided the rest of your stack supports it.
If you encounter specific configuration issues after installation, such as token guard setup or database migrations failing, ensure your .env file matches the expectations of the Laravel 8 release cycle. For further guidance on securing OAuth2 setups within the Laravel ecosystem, resources like https://laravelcompany.com provide documentation on best practices for authentication management.
