由于版本不兼容,无法安装 laravel/sail
我正在尝试将 laravel/sail 安装到现有项目中,该项目之前似乎没有安装过。我相信这个项目通常在 vagrant 上运行。
我正在尝试使用 Laravel Sail 在 WSL2 上运行它。我也不完全确定这是否是我的情况下的最佳方法。
我的理解是,我可以使用 sail 通过 docker 运行项目,只需最少的设置和配置。
当我尝试通过 Composer 安装 sail 时,似乎出现错误。这些是我遵循的说明: https:// /laravel.com/docs/9.x/sail#installing-sail-into-existing-applications
这是错误:
$ composer require laravel/sail --dev
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20190902/pdo_mysql (/usr/lib/php/20190902/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0
Using version ^1.13 for laravel/sail
./composer.json has been updated
Running composer update laravel/sail
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 laravel/sail ^1.13 -> satisfiable by laravel/sail[v1.13.0, ..., 1.x-dev].
- laravel/sail[v1.13.0, ..., 1.x-dev] require illuminate/contracts ^8.0|^9.0 -> found illuminate/contracts[v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/sail:*" to figure out if any version is installable, or "composer require laravel/sail:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
我不完全确定如何解释这个,但它看起来像那个版本尝试安装的包与另一个所需的包不兼容。
composer.json
文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.4",
"composer-runtime-api": "^2.0",
"aws/aws-sdk-php-laravel": "^3.6",
"doctrine/dbal": "^2.8",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^7.3",
"laravel/framework": "6.*",
"laravel/nexmo-notification-channel": "^2.5",
"laravel/passport": "9.4.*",
"laravel/tinker": "^1.0",
"maatwebsite/excel": "^3.1",
"nexmo/laravel": "^2.4",
"rap2hpoutre/laravel-log-viewer": "1.7.*",
"spatie/laravel-uptime-monitor": "^3.7",
"vonage/client": "^2.4"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.8",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.1"
},
"autoload": {
"classmap": [
"database",
"app/Http/Controllers",
"app/Console/Commands"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"platform": {
"php": "7.4"
},
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
I'm trying to install laravel/sail
into an existing project, which doesn't appear to have had it installed before. This project is normally run on vagrant I believe.
I'm trying to get it running on WSL2, using Laravel Sail. I'm also not entirely sure if that's the best approach in my case.
My understanding is that I can use sail to get the project running via docker, with minimal setup and configuration.
I seem to be getting an error when I try to install sail via composer. These are the instructions I'm following: https://laravel.com/docs/9.x/sail#installing-sail-into-existing-applications
Here's the error:
$ composer require laravel/sail --dev
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20190902/pdo_mysql (/usr/lib/php/20190902/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0
Using version ^1.13 for laravel/sail
./composer.json has been updated
Running composer update laravel/sail
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 laravel/sail ^1.13 -> satisfiable by laravel/sail[v1.13.0, ..., 1.x-dev].
- laravel/sail[v1.13.0, ..., 1.x-dev] require illuminate/contracts ^8.0|^9.0 -> found illuminate/contracts[v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/sail:*" to figure out if any version is installable, or "composer require laravel/sail:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I'm not entirely sure how to interpret this, but it looks like the version that is attempting to be installed is not compatible with another required package.
composer.json
file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.4",
"composer-runtime-api": "^2.0",
"aws/aws-sdk-php-laravel": "^3.6",
"doctrine/dbal": "^2.8",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^7.3",
"laravel/framework": "6.*",
"laravel/nexmo-notification-channel": "^2.5",
"laravel/passport": "9.4.*",
"laravel/tinker": "^1.0",
"maatwebsite/excel": "^3.1",
"nexmo/laravel": "^2.4",
"rap2hpoutre/laravel-log-viewer": "1.7.*",
"spatie/laravel-uptime-monitor": "^3.7",
"vonage/client": "^2.4"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.8",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.1"
},
"autoload": {
"classmap": [
"database",
"app/Http/Controllers",
"app/Console/Commands"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"platform": {
"php": "7.4"
},
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,您将无法使用
laravel/sail
基于您当前的 Laravel 框架版本。说明:
laravel/sail="1.13" 需要
Illuminate/contracts
: ^8.0|^9.0`现在,问自己一个问题,Laravel v6 中哪些包依赖于
Illuminate/contracts
?命令:
composerdependsIlluminate/contracts
输出:
根据上面的输出,您会意识到常见Illuminate/contracts< /em> 所有依赖项之间的版本为
^6.0
。考虑到这一点,您通常需要安装需要
Illuminate/contracts
的laravel/sail
版本:^6.0`不幸的是,不是强>可能。之所以如此,是因为即使是第一个
laravel/sail
版本 (<代码>开发开发)需要照明/合约
:^8.0|^9.0|^10.0。现在,最合理的选择是首先升级项目中依赖于Illuminate/contracts的软件包。上面输出中的所有 3 个包中,有一个是 Laravel 框架。遗憾的是,第一个满足
Illuminate/contracts: ^8.0|^9.0
要求的框架版本是laravel/framework v8.0.0
。如果您会考虑这一点,那么您可能需要查看 Laravel 8 升级指南。可能的解决方案:
考虑到 Laravel Sail 只是一个为您提供起点的工具要使用 PHP、MySQL 和 Redis 构建 Laravel 应用程序,而不需要具备 Docker 经验,还有其他工具可以以类似的方式完成工作。
我建议使用的一个工具是 Laradock。
如果您有足够的 docker 经验,您甚至可以借助 Docker Hub。
Unfortunately, you won't be able to work with
laravel/sail
based on your current Laravel framework version.Explanation:
laravel/sail="1.13" requires
illuminate/contracts
: ^8.0|^9.0`Now, ask yourself a question, what packages depend on
illuminate/contracts
in Laravel v6?Command:
composer depends illuminate/contracts
Output:
Based on the output above, you kind of realize that the common illuminate/contracts version between all dependents is
^6.0
.With that in mind, you would normally need to install a
laravel/sail
version that requiresilluminate/contracts
: ^6.0`Unfortunately, that isn't possible. This is so because even the first
laravel/sail
version (dev-develop
) requiresilluminate/contracts
: ^8.0|^9.0|^10.0.Now, the most reasonable option would be to first upgrade the package(s) that depend on illuminate/contracts in your project. Among all 3 packages in the output above, is the Laravel framework. Sadly enough, the first framework version that meets the
illuminate/contracts: ^8.0|^9.0
requirement islaravel/framework v8.0.0
. If that is something you would consider, then you may want to look at the Laravel 8 upgrade guide.Possible solution:
Considering that Laravel Sail is simply a tool to provide you with a starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience, there are other tools that can get the job done in a similar fashion.
One tool I may suggest is Laradock.
If you have enough docker experience, you could even roll out your own docker set-up from scratch with the help of readily available public official docker images from Docker Hub.
要解决此问题并避免某些依赖项的不兼容,您可以运行:
但这不是一个很好的做法。
To fix this and avoid the incompatibility of certain dependencies, you can run:
But it's not a very good practice.