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


Symfony STDIN error when install via composer

我尝试在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]

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

php app/console assets:install web

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

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

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

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

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