Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

php bin/console says it cannot open the input file

ErrorCould not open input file: bin/console

Short answer

PHP could not find a file called bin/console relative to the folder you are in. Run the command from the Symfony project root, the folder that holds composer.json. If the file is not there at all, the project has no Console component yet: install symfony/console with Composer.

  • Applies to Symfony 7.4, Symfony 8.1, PHP 8.4, Composer 2
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check where you are and whether the file exists from there.

    pwd
    ls -l bin/console composer.json
  2. 2Match what you see, then jump to its fix

    1. 1ls: bin/console: No such file or directory, but the project exists a level up or downThe command runs from the wrong folderFix
    2. 2bin/ has no console file, and composer.json has no symfony/console entryThe project has no bin/console because the Console component is missingFix

What does the error look like?

  • Could not open input file: bin/console

Cause 1 of 2

The command runs from the wrong folder

1Check

The path bin/console is relative to the current folder. The Symfony docs run it from inside the project directory, the one created by symfony new or composer create-project.

pwd
ls

2Fix

Change into the project root, then run the console from there.

cd /path/to/my-project
php bin/console about

3Verify

The about command prints the Symfony version and environment.

php bin/console list

Confirmed by symfony.com

Did this fix it?

Cause 2 of 2

The project has no bin/console because the Console component is missing

1Check

Symfony applications include the Console component by default; other PHP projects need it installed with Composer. If the project uses Symfony Flex, the symfony/console recipe provides the bin/console file.

grep -n "symfony/console" composer.json
ls bin/

2Fix

Install the component. Flex then applies the recipe and writes bin/console.

composer require symfony/console

3Verify

The file exists and lists the available commands.

ls -l bin/console
php bin/console list

Confirmed by symfony.com

Did this fix it?

How do I stop it coming back?

  • Start every Symfony session with cd into the project root; a shell prompt that shows the folder name helps.
  • After cloning an existing project run composer install before the first console command.
  • In scripts and CI, cd to the project root first or call the file with its full path.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Apache returns 403 when a URL contains %3F

a request like /page%3Fname=test is refused while /page?name=test works

Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.