« HOME

Automating the creation of new symfony 1.4 projects (doctrine + git)

By Nacho Martín on 15 May 2010

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.

Written by @nacmartin

blog comments powered by Disqus

» ALL POSTS