Create blank Symfony2 project with single command (copy/paste)

Janusz Slota - Thu 09 January 2014 - php, symfony2, bash, one-liner

Every time I start new Symfony project, I always go to composer website to get latest composer, then to Symfony to get command to create new project. After that, I remove AcmeDemoBundle and initialise git and git-flow. But that's enough.

Here, I give you my script to generate blank Symfony2 project. It's one (long) line of bash code (broken down for readability). Just copy and paste in your terminal.

It works on OSX and Linux, requires only bash, curl, php, and patch. It may work on Windows (with Cygwin or something similar), but I haven't tried that.

With a little bit of AngularJS, I've made it parametrised. You can change your project folder and Symfony version and choose to remove (or not) AcmeDemoBundle.

You can also initialise git repository and git-flow. But you need to have these already installed on your system.

Enjoy!

curl -sS https://getcomposer.org/installer | php && \
./composer.phar -n create-project symfony/framework-standard-edition {{path}}/ {{version}} && \
mv composer.phar ./{{path}}/bin/ && \
cd ./{{path}}/ && \
curl https://raw2.github.com/nixilla/php-dev-stack/master/remove_acme.diff | patch -p1 && \
rm -rf src/Acme && \
cd .. && \
cd ./{{path}}/ && \
rm LICENSE UPGRADE* .travis.yml && \
echo '' > README.md && \
git init && git add . && git commit -m "Initial commit" && \
cd .. && \
cd ./{{path}}/ && \
git flow init -d && \
cd ..