【问题标题】:Symfony STDIN error when install via composer通过作曲家安装时出现 Symfony STDIN 错误
【发布时间】:2017-09-21 13:21:25
【问题描述】:

我尝试使用命令在 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]

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

php app/console assets:install web

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

【问题讨论】:

    标签: php symfony composer-php stdin


    【解决方案1】:

    这个错误可能是因为你的php安装的是CGI binary模式,而不是CLI。解决此问题的方法可能是在 AppKernel.php 文件的顶部添加以下行:

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2019-11-28
        • 2018-03-20
        • 2016-02-14
        • 2016-03-23
        • 2016-02-21
        • 2016-08-07
        • 2012-11-29
        • 1970-01-01
        • 2014-06-17
        相关资源
        最近更新 更多