Automating the creation of new symfony 1.4 projects (doctrine + git)
Sometimes I want to create new symfony projects to try something, or, well, sometimes even to do some actual work.
Then, I go to the Jobeet tutorial and follow the first steps. After that, since I use git, I check out this post to setup symfony as a submodule.
I have written a simple bash script with that post and a few more lines, to automatize the process. It may be useful for others, and for me to have it accesible, so I will post it here:
setupsymfony.sh:
#!/bin/bash SYMFREPO="git://symfony-git.git.sourceforge.net/gitroot/symfony-git/symfony-git" DBUSER="root" DBPASS="" VENDOR_DIR="lib/vendor/symfony" if [ -z "$DBPASS" ]; then echo edit setupsymfony.sh to add your mysql password on line 4: DBPASS=\"password\" exit fi if [ -z "$1" ]; then echo usage: $0 project name exit fi mkdir $1 cd $1 git init git clone $SYMFREPO $VENDOR_DIR git submodule add $SYMFREPO $VENDOR_DIR/ git submodule foreach 'git submodule init && git submodule update' git commit -m 'Initial commit; initialized symfony-git (1.4)' $VENDOR_DIR/data/bin/symfony generate:project $1 echo "config/databases.yml" > .gitignore echo "cache/*" >> .gitignore echo "log/*" >> .gitignore ./symfony project:permissions git add . git commit -m 'Initialized symfony project' ./symfony generate:app frontend git add . git commit -m 'Initialized frontend application' mysqladmin -u$DBUSER -p$DBPASS create $1 ./symfony configure:database "mysql:dbname=$1;hostname=localhost" $DBUSER $DBPASS
usage: ./setupsymfony.sh name_of_the_new_project
remember to write your database password in the line 4 of the script.
#Edit: updated to include the changes proposed by kbsali. Thanks!
#Edit2: I have posted it in a gist.
Nice one!
I just tried it and it works great,
i just made 2 changes :
- use the SYMFREPO variable ;)
- add a VENDOR_DIR variable so you can more easily change the path where the framework will sit.
…
SYMFREPO=”git://symfony-git.git.sourceforge.net/gitroot/symfony-git/symfony-git”
DBUSER=”root”
DBPASS=”"
VENDOR_DIR=”vendor/symfony”
…
git clone $SYMFREPO $VENDOR_DIR
git submodule add $SYMFREPO $VENDOR_DIR/
…
$VENDOR_DIR/data/bin/symfony generate:project $1
…
Thanks!
Ooops, true, I forgot to use it. Good changes, I have updated the post with them.
Yay !
Well done, thanks for this very useful script :)
Hi nacho,
Just got back playing with symfony+git after so many months. I haven’t had updated any of the how-to’s yet, but I wanna share this to you first. I got the setup easier:
$ mkdir project
$ git init
$ git submodule add -b 1.4.6-agi git://symfony-git.git.sourceforge.net/gitroot/symfony-git/symfony-git lib/vendor/symfony
$ git submodule update –recursive
$ lib/vendor/symfony/data/bin/symfony -V
$ lib/vendor/symfony/data/bin/symfony generate:project symfony-git
I also haven’t touched on the details just yet. Hopefully you get to play with it and looking for your insights…
Thanks :-)
Ok, thanks! I will update it soon. Btw, at the moment, the git repository is not working, so I’m using this one: http://github.com/vjousse/symfony-1.4 instead, in case someone has problems with the repo.