通过bash脚本运行php Doctrine命令

I'm currently developing a PHP application using Symfony and Doctrine. My goal at this point is to create a bash script to build my database schema and load fixtures. My current script lives in the /bin folder and has the following content:

#!/usr/bin/env bash

php bin/console doctrine:migrations:migrate
php bin/console doctrine:fixtures:load --purge-with-truncate

The script is executable and when I try to run it (./create_de.sh), I get the following error:

Could not open input file: bin/console

I tried to change the script to be the following:

#!/usr/bin/env bash

php console doctrine:migrations:migrate
php console doctrine:fixtures:load --purge-with-truncate

But I still get the same error, except without the bin part.

When I run the commands in the script via command line I have no problems. Any idea why this script doesn't work?

Since the script lives inside the bin folder, just change it to:

php ./console doctrine:migrations:migrate
php ./console doctrine:fixtures:load --purge-with-truncate

Edit: there isn't any permissions issue here as other comments suggest, as the permissions of the console file are by default -rwxr-xr-x which means everyone can execute it.

have you tried (from within bin/) dos2unix create_de.sh > create_de_new.sh, then ./create_de_new.sh?

Did you check your permissions, the file bin/console must to have execution permissions:

Something like:

chmod +x bin/console