用composer部署laravel框架时,需要先保证已经安装composer成功,如下图所示:
这是在 composer 安装laravel框架时,出现的报错如下:
O:\phpstudy_new\PHPTutorial\WWW>composer create-project laravel/laravel=5.6.* laravel --prefer-dist
Creating a "laravel/laravel=5.6.*" project at "./laravel"
[InvalidArgumentException]
Could not find package laravel/laravel with version 5.6.*.
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--reposit
ory REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-s
cripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-req IGNORE-PLAT
FORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package>] [<directory>] [<version>]
Could not find package laravel/laravel with version 5.6.*.,不能找到包,说明是下载的镜像地址问题。从而导致无法找到框架包。
解决方案如下:
切换composer的镜像地址为阿里云镜像,
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
然后再去部署laravel项目:
composer create-project --prefer-dist laravel/laravel bbs "5.6.*"
--prefer-dist 是去下载压缩包,避免源码下载,上传速度慢等现象。