Skip to content

Instantly share code, notes, and snippets.

@sumpygump
Created April 22, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumpygump/11183669 to your computer and use it in GitHub Desktop.
Save sumpygump/11183669 to your computer and use it in GitHub Desktop.
Universal app/console for Symfony applications
#!/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