![]() |
|
Snippets |
|
You cannot call the symfony command like 'symfony cc' if you are not located in the project root directory.
Then, let's make a small script named 'sf' that executes the symfony command by looking for the project root directory.
If your server has Ruby ...
#!/usr/bin/env ruby #sf.rb — a symfony command wrapper require “FileUtils” until File.file?(“symfony”) FileUtils.cd(‘..’) raise “can’t find symfony project directory” if FileUtils.pwd == “/” end cmd = “symfony “ << ARGV.join(” “) puts cmd system(cmd)
(this is quote from http://blog.symfony.jp/2006/11/30/wrapping-symfony-command/)
If your server has Python ...
#!/usr/bin/env python import os,sys,string while os.getcwd() != "/" : for x in [n for n in os.listdir(os.getcwd()) if string.lower(n) == "symfony"] : print "project root: " + os.getcwd() os.system('symfony ' + " ".join(sys.argv[1:])) sys.exit(0) else: os.chdir('..') else: print "can't find symfony project" sys.exit(1)
(this is quote from http://d.hatena.ne.jp/brtRiver/20070121/1169339958)
if you like shell-script...
#!/bin/sh # -*- shell-scrpt -*- while [ 1 ]; do if [ -f 'symfony' ]; then symfony $* exit $? fi cd .. if [ "$PWD" = "/" ]; then echo 'cannot find symfony project directory' exit 1 fi done
(this is quote from http://d.hatena.ne.jp/hilde/20070204)
You also need to do 'chmod +x' to this script.
Wherever you are, you can call 'symfony' command via 'sf' like this
$ sf cc
the include path of your system must include the path to this script.