php 尝试运行 Symfony 应用程序时出现“无法打开输入文件:bin/console”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34016449/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:42:37  来源:igfitidea点击:

"Could not open input file: bin/console" Error comes when try to Run the Symfony Application

phpsymfony

提问by vimuth

$ cd my_project_name/
$ php bin/console server:run

When I added following commands and tried to run my symfony application this error comes,

当我添加以下命令并尝试运行我的 symfony 应用程序时,出现此错误,

"Error:Could not open input file: bin/console"

“错误:无法打开输入文件:bin/console”

回答by vimuth

As @chapay and @cered says we can use this command instead.

正如@chapay 和@cered 所说,我们可以改用这个命令。

php app/console server:run

Its Symfony 2 command and the one I had problems with is Symfony 3 command. And I found out few other times also this issue comes.

它的 Symfony 2 命令和我遇到的问题是 Symfony 3 命令。我发现其他几次也出现了这个问题。

for sometimes we can replace 'bin' with 'app'. like,

因为有时我们可以用“app”替换“bin”。喜欢,

php bin/console doctrine:mapping:import --force AcmeBlogBundle xml
php app/console doctrine:mapping:import --force AcmeBlogBundle xml

And if not we can choose the correct command in 'http://symfony.com/doc/' site by changing the version.

如果不是,我们可以通过更改版本在“ http://symfony.com/doc/”站点中选择正确的命令。

enter image description here

在此处输入图片说明

回答by Lucian P.

The file app/console was moved to bin/console in Symfony 3. So instead of running

在 Symfony 3 中,文件 app/console 被移动到 bin/console。所以而不是运行

php bin/console server:run      #valid in Symfony 3

Try running:

尝试运行:

php app/console server:run      #valid in Symfony 2

回答by Alexey Vilchansky

Before to use this command make sure you installed dependencies from composer.json
Run:

在使用此命令之前,请确保您从 composer.json 安装了依赖项
运行:

composer update

作曲家更新

回答by Inoubli

also make sure you are under the project folder (cd your_project), else it gives you the same error ( Could not open input file: bin/console )

还要确保你在项目文件夹下(cd your_project),否则它会给你同样的错误(无法打开输入文件:bin/console)

回答by Rowayda Khayri

It works when I use start instead of run : php app/console server:start

当我使用 start 而不是 run 时它有效:php app/console server:start

回答by Andrew Zhilin

If you use git - you should check if bin/console is added to repository. Some versions may have .gitignore in bin/ folder, so bin/console may work on your local PC and not work on server because of it.

如果您使用 git - 您应该检查 bin/console 是否已添加到存储库。某些版本可能在 bin/ 文件夹中包含 .gitignore,因此 bin/console 可能会在您的本地 PC 上运行,而无法在服务器上运行。