[英]Installing Laravel using Composer through PhpStorm
I have checked out many examples of this but for some reason, either I am missing an assumed step or I'm just doing it wrong. 我已经检查了很多这样的示例,但是由于某种原因,或者我错过了一个假定的步骤,或者我做错了。
So I am having issues getting Laravel installed locally. 所以我在本地安装Laravel时遇到问题。 I have a composer.json
and .phar file. 我有一个composer.json
和.phar文件。
I have ran php composer install
which downloaded the dependencies. 我已经运行php composer install
,下载了依赖项。 However, this is where it gets different. 但是,这是与众不同的地方。 Seems at this point all the examples I have found are magically working. 在这一点上,我发现的所有示例似乎都在神奇地工作。 However in mine, I have a vendor directory with all the dependencies but nothing is actually installed. 但是在我的公司中,我有一个包含所有依赖项的供应商目录,但实际上未安装任何东西。 I have the Laravel source but its not ready for development yet. 我有Laravel资源,但尚未准备好开发。
Does this make sense? 这有意义吗? Am I over complicating things? 我是否使事情复杂化?
I am now getting an error: 我现在收到一个错误:
Script php artisan optimize handling the post-update-cmd event returned with error code 1 脚本php artisan优化处理错误代码为1返回的post-update-cmd事件
which after checking, that method is there... 经过检查后,该方法在那里...
My composer.json: 我的composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"barryvdh/laravel-cors": "^0.8.2"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
} }
It looks like you may have downloaded Laravel itself instead of creating a Laravel project. 看来您可能已经下载了Laravel本身,而不是创建了Laravel项目。
The Installing Laravel section of the documentation shows two ways to create a Laravel project: 文档的“ 安装Laravel”部分显示了创建Laravel项目的两种方法:
Via Laravel Installer 通过Laravel安装程序
First, download the Laravel installer using Composer: 首先,使用Composer下载Laravel安装程序:
composer global require "laravel/installer"
Make sure to place the
$HOME/.composer/vendor/bin
directory (or the equivalent directory for your OS) in your$PATH
so thelaravel
executable can be located by your system. 确保将$HOME/.composer/vendor/bin
目录(或操作系统的等效目录)放在$PATH
以便系统可以定位laravel
可执行文件。Once installed, the
laravel new
command will create a fresh Laravel installation in the directory you specify. 安装完成后,laravel new
命令将在您指定的目录中创建一个全新的Laravel安装。 For instance,laravel new blog
will create a directory namedblog
containing a fresh Laravel installation with all of Laravel's dependencies already installed: 例如,laravel new blog
将创建一个名为blog
的目录,其中包含一个全新的Laravel安装,其中已经安装了所有Laravel的依赖项:laravel new blog
Via Composer Create-Project 通过Composer创建项目
Alternatively, you may also install Laravel by issuing the Composer
create-project
command in your terminal: 或者,您也可以通过在终端中发出Composercreate-project
命令来安装Laravel:composer create-project --prefer-dist laravel/laravel blog
After doing either of these your project directory should include the proper Laravel directories with all dependencies properly set up. 完成上述任一操作后,您的项目目录应包括正确的Laravel目录,并正确设置了所有依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.