php 无法打开输入文件应用程序/控制台

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

Could not open input file app/console

phpsymfony

提问by Zoha Ali Khan

I installed wamp server and a copy of the Symfony2 framework. I am trying to create a Bundle, using the following command:

我安装了 wamp 服务器和 Symfony2 框架的副本。我正在尝试使用以下命令创建一个 Bundle:

php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml

My PHP is in C:/wamp/bin/php/php5.3.10

我的 PHP 在 C:/wamp/bin/php/php5.3.10

But when I run the command it says:

但是当我运行命令时,它说:

could  not open input file app/console

Can anyone tell me what is going wrong?

谁能告诉我出了什么问题?

回答by Parixit

To execute command you should move to root directory of your project in terminal/CMD.

要执行命令,您应该移动到终端/CMD 中项目的根目录。

Please note that in version 2.5some changes has been made so command will not work with app/console

请注意,在version 2.5某些更改中已进行,因此命令将无法使用app/console

Note:From 2.5 app/consoleis replaced by bin/console.

注意:从 2.5 开始app/console替换为bin/console.

Please check herefor changes. Also check thisfor more details about difference.

在此处查看更改。另请检查以获取有关差异的更多详细信息。

回答by Faryal Khan

Dont run the command from the php path.

不要从 php 路径运行命令。

Add php into your path environment variable

将 php 添加到您的路径环境变量中

and then cd to the project

然后cd到项目

C:/wamp/www/yourproject

and then run the command

然后运行命令

php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml

It will work

它会工作

回答by Imran Zahoor

For newer versions of Symfony (2.4.x or newer) use this method on windows to resolve the problem:

对于较新版本的 Symfony(2.4.x 或更新版本),在 windows 上使用此方法来解决问题:

  1. Go to project directory e.g. d:/xampp/symfony2-project/ and open composer.json and place this under requires array "symfony/console": "2.4.*@dev". And save the file.
  2. Open command-line and cd to project's directory.
  3. Use this command to let download and install the dependencies: php path/to/composer.phar install. Remember you should be in your project's directory and path/to/composer.phar is the actual path to your composer.phar file.
  4. Now you are all done, just use php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml
  1. 转到项目目录,例如 d:/xampp/symfony2-project/ 并打开 composer.json 并将其放在 requires array 下"symfony/console": "2.4.*@dev"。并保存文件。
  2. 打开命令行并 cd 到项目目录。
  3. 使用此命令让下载和安装依赖项:php path/to/composer.phar install. 请记住,您应该位于项目目录中,而 path/to/composer.phar 是 composer.phar 文件的实际路径。
  4. 现在你已经完成了,只需使用 php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml

回答by Zoha Ali Khan

Actually You need to be in your project root to run this command and you have to add php directory to your system env path variable.

实际上,您需要在项目根目录中才能运行此命令,并且必须将 php 目录添加到系统 env 路径变量中。

  1. Add your php directory to the system path variable
  2. cd to the root of your project
  1. 将您的 php 目录添加到系统路径变量中
  2. cd 到项目的根目录

回答by juanitourquiza

I'm use Symfony 3 and the Bundle calendar-bundle. This error is present in the documentation of: Bundle: https://github.com/adesigns/calendar-bundle

我正在使用 Symfony 3 和 Bundle calendar-bundle。此错误存在于以下文档中:Bundle: https://github.com/adesigns/calendar-bundle

The form correct is:

正确的形式是:

php bin/console assets:install web 

Regards

问候

回答by pavan ganvani

First check the Environment Variable which is in Advanced system setting -> set path of C:/wamp/www/bin/phpand then

首先检查高级系统设置中的环境变量 - >设置路径,C:/wamp/www/bin/php然后

run cmd->go to the directory of your project which is in www folder using cd C:/wamp/www/yourproject

运行 cmd-> 使用 cd 转到 www 文件夹中的项目目录 C:/wamp/www/yourproject

use then user php app/consolethat shows the all command.

使用 thenphp app/console显示 all 命令的用户。

回答by Peter Bailey

Sounds like you (i.e., your user) don't have access to read/execute console. I've never worked with with file permissions on a WAMP stack so I'm not sure what you'll need to do to fix them.

听起来您(即您的用户)无权访问 read/execute console。我从来没有处理过 WAMP 堆栈上的文件权限,所以我不确定你需要做什么来修复它们。

回答by Carlos Perez Perez

It is also possible that you have the line :

您也可能有以下线路:

//umask(0000);

in your /webfile, app_dev.php.

在您的/web文件中,app_dev.php.

If after doing :

如果在做之后:

php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml

in your project path, you still can not generate your bundle, try uncommenting the unmask line. It worked for me.

在您的项目路径中,您仍然无法生成您的包,请尝试取消注释取消屏蔽行。它对我有用。

回答by Lahiru Pinto

I got the same issue when installing the pear library

安装梨库时我遇到了同样的问题

my issue was, when downloading the go-pear.phar file, it downloads as the (.txt) extensionwhich i didn't see.

我的问题是,在下载go-pear.phar 文件时,它下载为我没有看到的 (.txt) 扩展名

jst change the file extension to .phar and run the code

jst 将文件扩展名更改为 .phar 并运行代码