php bin/console says it cannot open the input file
Could not open input file: bin/consoleShort 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.
Fix it fast
1Find out which cause you have
Check where you are and whether the file exists from there.
pwd ls -l bin/console composer.json2Match what you see, then jump to its fix
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
ls2Fix
Change into the project root, then run the console from there.
cd /path/to/my-project
php bin/console about3Verify
The about command prints the Symfony version and environment.
php bin/console listConfirmed by symfony.com
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/console3Verify
The file exists and lists the available commands.
ls -l bin/console
php bin/console listConfirmed by symfony.com
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
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack 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 fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix