php 无法打开输入文件:工匠
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26193314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not open input file: artisan
提问by wessodesigner
When trying to create a new laravel project, The following error appears on the CLI:
尝试创建新的 Laravel 项目时,CLI 上出现以下错误:
Could not open input file: artisan
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
无法打开输入文件:工匠
脚本 php artisan clear-compiled 处理 post-install-cmd 事件返回错误
I am using the latest version of XAMPP v3.2.1 with PHP 5.5.15 and with mcrypt enabled (made sure of that by issuing the command php -m). And I am running windows 8.1
我正在使用最新版本的 XAMPP v3.2.1 和 PHP 5.5.15 并启用了 mcrypt(通过发出命令 php -m 确保这一点)。我正在运行 Windows 8.1
回答by Marcin Nabia?ek
You need to first create Laravel projectand if you already have one you need to go to this project dir using cd
command in terminal for example cd myproject
.
您需要首先创建 Laravel 项目,如果您已经有了一个,则需要使用cd
终端中的命令转到此项目目录,例如cd myproject
。
Now you will be able to run any artisan commands, for example running php artisan
will display you list of available commands.
现在您将能够运行任何工匠命令,例如运行php artisan
将显示可用命令列表。
回答by Yevgeniy Afanasyev
You cannot use php artisan
if you are not inside a laravel
project folder.
php artisan
如果您不在laravel
项目文件夹内,则无法使用。
That is why it says 'Could not open input file - artisan'
.
这就是为什么它说'Could not open input file - artisan'
。
回答by cyber8200
If you project is at /home/forge/laravel-project/
如果您的项目在 /home/forge/laravel-project/
You can properly execute your artisan like this
你可以像这样正确地执行你的工匠
php /home/forge/laravel-project/artisan ...
php /home/forge/laravel-project/artisan ...
回答by zaffar
Most probably you are not in the right directory!
很可能你不在正确的目录中!
回答by Kevin Carmody
I just needed to make artisan
executable.
我只需要制作artisan
可执行文件。
chmod +x artisan
chmod +x artisan
...and it works without the php prefix then.
...它可以在没有 php 前缀的情况下工作。
回答by John Zenith
First, be sure to be in the laravel project folder or else the terminal won't be able to locate the artisan
file in the project directory and any subsequent request you pulled to start a server would be rejected.
首先,请确保位于 laravel 项目文件夹中,否则终端将无法artisan
在项目目录中找到该文件,并且您为启动服务器而拉取的任何后续请求都将被拒绝。
Demo
演示
Let's say our laravel project name is blog
and located in C:\laravel
We then have: C:\laravel\blog
假设我们的 laravel 项目名称是blog
并且位于C:\laravel
我们然后有:C:\laravel\blog
Where to open terminal
在哪里打开终端
Navigate to the C:\laravel\blog
directory and open the command window (terminal). Input the code below:
导航到C:\laravel\blog
目录并打开命令窗口(终端)。输入以下代码:
Laravel terminal code to start server
Laravel 终端代码启动服务器
php artisan serve --host 127.0.0.1
php artisan serve --host 127.0.0.1
回答by Napster Scofield
You must must be in your Laravel Project Folder
你必须在你的 Laravel 项目文件夹中
When creating a new project with laravel new project-name
, a folder will be created with your project name as name. You must get in that folder before using any php artisan
command like php artisan serve
because the artisan file is in that folder
使用 新建项目时laravel new project-name
,将创建一个以您的项目名称作为名称的文件夹。您必须在使用任何php artisan
命令之前进入该文件夹,php artisan serve
因为工匠文件在该文件夹中
回答by Arman H
I also had the problem i just installed but forgot to jump the created project folder. So you need to jump your project folder.
我也遇到了刚刚安装但忘记跳转创建的项目文件夹的问题。所以你需要跳转你的项目文件夹。
cd project_name
cd 项目名称
and then serve php artisan command
然后提供 php artisan 命令
回答by Aamir Kalimi
Just make sure you are in the project folder by typing
只需通过键入确保您在项目文件夹中
ls
ls
If not then go to the project folder by typing
如果没有,则通过键入转到项目文件夹
cd folder_name
for example:
例如:
cd laravel
And then type
然后输入
php artisan serve
php artisan serve
回答by A.Aleem11
If it is your first install of laravel then create another directory/folder inside the laravel directory and then move to that empty folder and create another project using the command below:
如果这是您第一次安装 laravel,则在 laravel 目录中创建另一个目录/文件夹,然后移动到该空文件夹并使用以下命令创建另一个项目:
composer create-project --prefer-dist laravel/laravel blog
This will create a new project named "blog", then go back to parent laravel directory and now you can run this command:
这将创建一个名为“blog”的新项目,然后返回到父 laravel 目录,现在您可以运行以下命令:
php artisan serve
You will receive the return such as:
您将收到回报,例如:
laravel deployment server started: http://localhost:8000