r1pp3rj4ck's tech blog

Because software is like sex… it's better when it's free – and even better with a penguin.

Creating Symfony projects like a sir

I’m pretty sure many of you don’t like to download the latest version of Symfony Standard Distribution from symfony.com, install it, remove the AcmeDemoBundle from src directory and remove those stuff mentioning it every time you start a new project. I don’t like it either. Fortunately, I have a better way to do so.

hacfi from Freenode channel #symfony-dev suggested me a way to start new projects, the only thing I’ve done is to create a bash script to automatize it. So first thing you have to do is install composer:

$ curl -S http://getcomposer.org/installer | php

$ mv composer.phar /usr/bin/composer

This way you can reach composer from anywhere you want by typing “composer” to the shell – you don’t even have to type “php” or “phar”. Next thing you should do is put a record to your crontab so it would update itself regularly (or if you prefer, you can do manually when you want with “composer self-update”).

Here comes the real trick: create a nice function to your ~/.bashrc file:

The usage of this little script is:

$ create-symfony path version

For example you want to create a new Symfony 2.1.3 project called foo:

$ create-symfony foo 2.1.3

This command will create a directory foo containing a new Symfony 2.1.3 project, but without the Acme directory, every reference to it, the apple-touch-icon.png and the favicon.ico. Now you can work with it :)

UPDATE: the way I described leaves two unfinished routes in app/config/routing_dev.yml, which has to be removed manually (_demo and _demo_secure).

UPDATE 2: no need to manually remove _demo and _demo_secure path now.


Single Post Navigation

6 thoughts on “Creating Symfony projects like a sir

  1. cordoval on said:

    this is nice, but then why not creating a skeleton? and do rather composer create-project myproject/mysymfony-skeleton?

  2. Well, maybe that’s an easier solution :) I didn’t even think about that, despite I’m creating a custom distribution (closed :() for our own projects. The difference is that in our custom distribution is for projects with some special properties, which are similar to each other – so there will be some “pre-coded” stuff.

  3. Emanuele Gaspari on said:

    Hi, I’m Emanuele, the main developer of http://symfonybricks.com. After looking at your article, I invite you to have a look at this platform, where you could publish guides and recipes about Symfony.
    It is also possible post a guide (named “brick”) on SymfonyBricks, referencing the original article by specifying the canonical url.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: