Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[2.5][Console] Use of undefined constant STDIN - assumed 'STDIN' #10795

Closed
@barryvdh

Description

@barryvdh

The new Console QuestionHelper uses the constant STDIN which is only available when using PHP in CLI modus. This is usually fine for the console, but in some cases command's are called through the web php.
This worked in 2.4, but doesn't work in 2.5, even when not using the QuestionHelper, because the QuestionHelper is instantiated in the Console Application getDefaultHelperSet(), and the STDIN constant is used in the constructor.

Cases where this lead to errors:

  • Calling a command through a webinterface
  • Just loading the console application in a ServiceProvider
    (But both are probably not best practices, but I came across both when testing Laravel 4.2-dev, which uses Symfony 2.5)

Possible fixes:

  • Not use STDIN in the constructor, but set it when the inputstream is first used.
  • Check if STDIN is defined, if not, define it manually (define('STDIN',fopen("php://stdin","r"));), can prevent errors in the rest of the helpers also, but probably don't have the desired effect.)

(cc @taylorotwell for Laravel)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions