Universal app/console for Symfony applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script allows you to run `sf` instead of app/console and you don't have | |
# to be the root of a Symfony application. It will traverse the parent | |
# directories until it finds app/console. | |
targetfile=app/console | |
path=. | |
# Get the canonical directory of the current "path" | |
while [[ "`readlink -f $path`" != "/" ]]; | |
do | |
if [ -f $path/$targetfile ]; then | |
# If we found it, run it | |
echo `readlink -f $path`/$targetfile | |
cd $path | |
php app/console $* | |
# Return the same status code as what app/console returned with | |
exit $? | |
fi | |
# Move up a directory | |
path=${path}/.. | |
done | |
echo "Not in a symfony app: 'app/console' not found" | |
echo "I searched in parents all the way up to root" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment