通过composer安装时出现Symfony STDIN错误

时间:2015-03-01 12:07:38

标签: php symfony composer-php stdin

我尝试使用命令

在Windows 7上通过composer安装symfony
$ composer create-project symfony/framework-standard-edition www1

我收到错误

[ErrorException]
Use of undefined constant STDIN - assumed 'STDIN'

我需要做些什么来解决这个问题?

PS这是完整日志:

C:\WebServers\home\asd>composer create-project symfony/framework-standard-edition www1
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Installing symfony/framework-standard-edition (v2.6.4)
  - Installing symfony/framework-standard-edition (v2.6.4)
    Loading from cache

Created project in www1
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing doctrine/lexer (v1.0.1)
    Loading from cache

  - Installing doctrine/annotations (v1.2.3)
    Loading from cache

  - Installing twig/twig (v1.18.0)
    Loading from cache

  - Installing psr/log (1.0.0)
    Loading from cache

  - Installing doctrine/inflector (v1.0.1)
    Loading from cache

  - Installing doctrine/collections (v1.2)
    Loading from cache

  - Installing doctrine/cache (v1.4.0)
    Loading from cache

  - Installing doctrine/common (v2.4.2)
    Loading from cache

  - Installing symfony/symfony (v2.6.4)
    Loading from cache

  - Installing jdorn/sql-formatter (v1.2.17)
    Loading from cache

  - Installing doctrine/doctrine-cache-bundle (v1.0.1)
    Loading from cache

  - Installing doctrine/dbal (v2.4.4)
    Loading from cache

  - Installing doctrine/doctrine-bundle (v1.3.0)
    Loading from cache

  - Installing doctrine/orm (v2.4.7)
    Loading from cache

  - Installing incenteev/composer-parameter-handler (v2.1.0)
    Loading from cache

  - Installing sensiolabs/security-checker (v2.0.1)
    Loading from cache

  - Installing sensio/distribution-bundle (v3.0.16)
    Loading from cache

  - Installing sensio/framework-extra-bundle (v3.0.4)
    Loading from cache

  - Installing kriswallsmith/assetic (v1.2.1)
    Loading from cache

  - Installing symfony/assetic-bundle (v2.6.1)
    Loading from cache

  - Installing monolog/monolog (1.12.0)
    Loading from cache

  - Installing symfony/monolog-bundle (v2.7.1)
    Loading from cache

  - Installing swiftmailer/swiftmailer (v5.3.1)
    Loading from cache

  - Installing symfony/swiftmailer-bundle (v2.3.8)
    Loading from cache

  - Installing twig/extensions (v1.2.0)
    Loading from cache

  - Installing sensio/generator-bundle (v2.5.1)
    Loading from cache

kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
kriswallsmith/assetic suggests installing patchwork/jsqueeze (Assetic provides the integration with the JSqueeze JavaScript compressor)
kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
symfony/assetic-bundle suggests installing kriswallsmith/spork (to be able to dump assets in parallel)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing videlalvaro/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
Generating autoload files
Would you like to install Acme demo bundle? [y/N]


  [ErrorException]
  Use of undefined constant STDIN - assumed 'STDIN'



create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-cus
tom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [package] [directory] [version]

另外在应用程序中有3个空文件在“web / bundles”文件夹中,其中必须是包含css文件和图像的文件夹。因此,浏览器中的“web / app_dev.php”页面上没有图像。然后我执行了命令

php app/console assets:install web

并在“web / bundles”中出现图像和css文件,然后图像出现在“web / app_dev.php”页面上,以便正确显示。

2 个答案:

答案 0 :(得分:1)

可能会出现此错误,因为您的php已安装CGI binary模式,而不是CLI。对此的解决方法可能是放在AppKernel.php文件的顶部以下行:

define('STDIN',fopen("php://stdin","r"));

答案 1 :(得分:0)

我发现如果手动STDIN声明解决方案无法实现,以非交互模式(composer -n update)启动编辑器会有所帮助。

您可能需要删除生成提示的供应商文件夹,或者使用--prefer-source,但这是另一个故事。