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?
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
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.
Related
Is there a way to run terminal commands simultaneously
Like
php artisan serve
And
npm run dev (for laravel vite)
Run it in a comment or terminal with a shortcut
Yes. There is a creative way
You should define a variable in your command line
İf you're using linux run this command:
export part="php $PWD/artisan serve"
Note:part is variable name. Name it whatever you want (part stands for php artisan)
Note:by running this command the variable will accessible just in that CMD window. That means this way is a temporary way and if you want to access it all the time you need to add this command to your .bash or .profile file
I am trying to run a php file from shell script file or terminal in open-wrt platform. I have executed php files in crontab and those are running perfectly. i need to run a php file without putting it into crontab.I am trying it with the following command
chmod 777 /www/api/*
cd /www/api
php myphp.php
but it showing -ash: php: not found
I have also try it putting the following command on top of the script
#!/usr/bin/php
but it is not working. i could not figure out the problem!!!
You must install php-cli package, after you can run the script by
php-cli script.php
$ cd my_project_name/
$ php bin/console server:run
When I added following commands and tried to run my symfony application this error comes,
"Error:Could not open input file: bin/console"
As #chapay and #cered says we can use this command instead.
php app/console server:run
Its Symfony 2 command and the one I had problems with is Symfony 3 command. And I found out few other times also this issue comes.
for sometimes we can replace 'bin' with 'app'. like,
php bin/console doctrine:mapping:import --force AcmeBlogBundle xml
php app/console doctrine:mapping:import --force AcmeBlogBundle xml
And if not we can choose the correct command in 'http://symfony.com/doc/' site by changing the version.
The file app/console was moved to bin/console in Symfony 3.
So instead of running
php bin/console server:run #valid in Symfony 3
Try running:
php app/console server:run #valid in Symfony 2
Before to use this command make sure you installed dependencies from composer.json
Run:
composer update
also make sure you are under the project folder (cd your_project), else it gives you the same error ( Could not open input file: bin/console )
It works when I use start instead of run : php app/console server:start
If you use git - you should check if bin/console is added to repository. Some versions may have .gitignore in bin/ folder, so bin/console may work on your local PC and not work on server because of it.
In Symfony 6, somehow the bin folder is still ignored from git, even though it should be there.
You can check my other answer here: https://stackoverflow.com/a/73958225/9675721
create a fresh new symfony application
copy the /bin folder
if it is missing, copy the /config/packages folder as well
add these lines to .gitignore:
!/bin/
!/config/packages/*
I'm trying to setup phing to work with travis-ci, but I can't get it to run a setup script to get all the dependencies installed.
My .travis.yml file is:
language: php
php:
- 5.2
script: ./.travis-phing.sh
In travis, I get the error:
/home/travis/build.sh: line 105: ./.travis-phing.sh: Permission denied
What is causing that?
Solved
The script to be set to execute. I used:
chmod a+x .travis-phing.sh
Then simply commit, and push back to github.
Run the script using bash
Another option would be to run the script using bash, this would omit the need to modify the files' permissions.
bash path/to/file.sh
Alternatively:
sh path/to/file.sh
Note that
In this case you're not executing the script itself, you're executing bash or sh which then runs the script. Therefore the script does not need to be executable.
Make sense?
I've found this solution incredibly useful myself. I'm mainly running node & npm projects on travis-ci, those builds make use of the npm test command which you can configure to be anything.
I'm order to modify file permission I need to use sudo chmod ... on my local machine. But you can't always use sudo on travis-ci.
sh file.sh allows me to run my tests both locally and on travis-ci without having to manually update permissions.
I am learning Symfony, so I have only gotten to
Symfony/web/app_dev.php/demo/
But I'm still not able to find how to use command line.
I have shell access, but where to execute this command?
php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml
That command is meant to be run from your root symfony folder. If you have everything installed correctly, you should see the app directory listed when you use the ls command. If you don't see the app directory, either you didn't install correctly or your in the wrong folder on your system.
execute from root folder. The "console" (its a php file with no extension) file is in app/ folder. You can also go into that folder and run:
php console generate:bundle --namespace=Blogger/BlogBundle --format=yml