对教程所用的不可用 Composer 服务镜像的更新
教程中的 Homestead Box 对 Composer 服务使用 Laravel China 镜像 进行了加速,但是诚如作者所言,Laravel China 社区镜像现已经停止服务。
如果直接使用配好的环境去新建 Lavarel 项目,即执行如下命令:
composer create-project laravel/laravel Laravel --prefer-dist "5.8.*"
会出现如下的两种错误:
The "https://packagist.laravel-china.org/packages.json" file could not be downloaded: Peer certificate CN=*.phphub.org' did not match expected CN=packagist.laravel-china.org'
或
Content-Length mismatch https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
此时,我们就需要更换 Composer 服务的镜像为中国区的可用服务:Composer 国内加速:可用镜像列表。
取消 Composer 镜像配置的命令为:
composer config --unset repos.packagist
全局配置 Composer 镜像为阿里云的命令为:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
此后,你就可以继续来新建 Laravel 项目了。
推荐文章: