简体   繁体   English

无法安装 Laravel 6

[英]Cant install Laravel 6

I want to install Laravel 6 with Composer.我想用 Composer 安装 Laravel 6。 I try with that command:我尝试使用该命令:

composer create-project --prefer-dist laravel/laravel laravel6 "6.*"

But i get that result:但我得到了这个结果:

  [InvalidArgumentException]                                
  Could not find package laravel/laravel with version 6.*. 

Here is a screenshot这是一个截图

If i use:如果我使用:

composer create-project --prefer-dist laravel/laravel blog 

It install the v5.5.28 Here is a screenshot它安装了 v5.5.28这是一个截图

What can be the problem?可能是什么问题?

Which PHP version you are using?您使用的是哪个PHP版本? Laravel-6.* need PHP >= 7.2.0 . Laravel-6.*需要PHP >= 7.2.0 Check your server-requirements for Laravel 6.* .检查Laravel 6.*服务器要求 May be you did not meeting the requirements for laravel 6.* .可能是您没有满足laravel 6.*要求 And after meeting the requirements run your command inside htdocs folder for xampp or www folder for wamp webserver.在满足要求后,在xampphtdocs文件夹或wamp网络服务器的www文件夹中运行您的命令。

your command are no longer supports so you should use:您的命令不再受支持,因此您应该使用:

composer create-project --prefer-dist laravel/laravel="6.*" laravel6

You forgot to add the "--prefer-dist ".您忘记添加“--prefer-dist”。 So in your case, you have to use the:所以在你的情况下,你必须使用:

composer create-project laravel/laravel --prefer-dist

in order to make it work.为了使它工作。 So just remove all the files from: d:\xampp\htdocs\laravel and then try again by following the below commands to your cmd (I guess you are using Windows:):因此,只需从以下位置删除所有文件:d:\xampp\htdocs\laravel,然后按照以下命令重试您的 cmd(我猜您正在使用 Windows :):

 cd d:\xampp\htdocs\laravel

composer create-project laravel/laravel --prefer-dist作曲家创建项目 laravel/laravel --prefer-dist

I think this should work for you just fine我认为这应该对你有用

You don't need to specify the version of Laravel 6. By default, Laravel 6 installs the latest version and its extension.您不需要指定 Laravel 6 的版本。默认情况下,Laravel 6 安装最新版本及其扩展。

As I'm writing now the current and latest version of Laravel is: Laravel 6.0.4 The command below will install the current and the latest version in your laravel6 project.正如我现在写的那样,Laravel 的当前和最新版本是: Laravel 6.0.4 下面的命令将在您的 laravel6 项目中安装当前和最新版本。

composer create-project --prefer-dist laravel/laravel laravel6作曲家创建项目 --prefer-dist laravel/laravel laravel6

You don't need to specify the version of Laravel 6. By default, Laravel 6 installs the latest version and its extension.您不需要指定 Laravel 6 的版本。默认情况下,Laravel 6 安装最新版本及其扩展。

Via Composer Create-Project通过 Composer 创建项目

Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:或者,您也可以通过在终端中发出 Composer create-project 命令来安装 Laravel:

composer create-project --prefer-dist laravel/laravel your_project_name

I think it will be helpful for you.我想这对你会有帮助。 for more details visit laravel official website: https://laravel.com/docs/6.x/installation更多详情请访问 laravel 官网: https://laravel.com/docs/6.x/installation

Kindly upgrade your PHP version on your system.请在您的系统上升级您的 PHP 版本。

Then install laravel commands It will automatically install the lettest version depends on the PHP version.然后安装 laravel 命令它会自动安装 lettest 版本取决于 PHP 版本。

Or you can mention on laravel command and set the laravel version like "6.0*" behind the laravel installer command.或者您可以在 laravel 命令中提及,并将 laravel 版本设置为 laravel 安装程序命令后面的“6.0*”。

I hope this will works我希望这会奏效

Please check the permissions on the cache dir (/home/keynes/.composer/cache) It's complaining it cannot write to this dir, or it may not exist.请检查缓存目录(/home/keynes/.composer/cache)的权限它抱怨它不能写入这个目录,或者它可能不存在。 Maybe it is installing an older laravel version from the cache dir.也许它正在从缓存目录安装较旧的 laravel 版本。

The commands you are running should work.您正在运行的命令应该可以工作。 I would try clearing the composer cache:我会尝试清除作曲家缓存:

composer clear-cache

and then接着

composer update
composer create-project --prefer-dist laravel/laravel="6.*" laravel6

before trying again.在再次尝试之前。 Looking at the screenshots there seem to be some permissions errors in the ~/.composer directory.查看屏幕截图,在~/.composer目录中似乎存在一些权限错误。 This might also cause the composer clear-cache command to fail with an error.这也可能导致composer clear-cache命令失败并出现错误。

So if clearing the cache doesn't work or you get an error, you might try moving the ~/.composer directory to a backup location, to force composer to regenerate it's settings.因此,如果清除缓存不起作用或出现错误,您可以尝试将~/.composer目录移动到备份位置,以强制 composer 重新生成它的设置。

mv ~/.composer ~/.composer.backup

And then try it again (be aware that composer update will likely take a noticeably longer time than usual and might be unresponsive for a while):然后再试一次(请注意, composer update可能会比平时花费明显更长的时间,并且可能会在一段时间内无响应):

composer update
composer create-project --prefer-dist laravel/laravel="6.*" laravel6

If it still doesn't work, then you can restore the backup:如果它仍然不起作用,那么您可以恢复备份:

rm -rf ~/.composer
mv ~/.composer.backup ~/.composer

Then looking at the output of然后看output的

composer config --list --global

might help determine the next thing to try.可能有助于确定接下来要尝试的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM