使用composer安装Laravel11,出现以下错误:
composer create-project laravel/laravel example-app
Creating a "laravel/laravel" project at "./example-app"
- Installing laravel/laravel (v11.1.1): Extracting archive
Created project in D:\ProgramFiles\phpstudy_pro\WWW\laravel11.cc\example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependenciesYour requirements could not be resolved to an installable set of packages. Problem 1 - laravel/framework[v11.9.0, ..., v11.9.2] require fruitcake/php-cors ^1.3 -> found fruitcake/php-cors[dev-feat-setOptions, dev-master, dev-main, dev-test-8.2, v0.1.0, v0.1.1, v0.1.2, v1.0-alpha1, ..., 1.2.x-dev (alias of dev-master)] but it does not match the constraint. - Root composer.json requires laravel/framework ^11.9 -> satisfiable by laravel/framework[v11.9.0, v11.9.1, v11.9.2].
如下图所示:
问题原因解析:
因为laravel包是在国外,我们在配置composer的时候可能都设置为国内的镜像,如阿里云,华为云等
解决方法:
1、取消全局配置
composer config -g --unset repos.packagist
2、查看镜像地址,看下是否配置成功
composer config -g -l
3、再次执行安装命令
composer create-project laravel/laravel example-app
可以看到已经成功安装了。
注:条件允许的情况下可以挂vpn,这样下载更快,因为laravel框架是国外的。
最后,再次更换回来阿里云镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
文章评论(4)
遇见2024-06-29 14:12:09
66回复
遇见2024-06-29 14:44:48
88回复