简体   繁体   中英

Running php Doctrine commands via bash script

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.

您是否尝试过(从bin/dos2unix create_de.sh > create_de_new.sh ,然后是./create_de_new.sh

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

Something like:

chmod +x bin/console

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM