You heard me right, get ready to kiss your git clone’s good-bye with composer. If before you were accustomed to:
git clone git://github.com/username/repoName.git .
Then you would usually run more commands to get actually setup. And guess what, we don’t have time and we don’t have enough info for that. As PHP devs we are to get things done fast and in the best elegant way.
No more. Composer is here!
Sometimes we ignore that composer is all we need to start in the world of PHP. Today we are going to talk about the create-project command found in composer. I will assume you have a composer dev version installed on another folder and symlinked to /usr/bin/composer. The ability to bootstrap with dependencies ready a complete skeleton application lies into one command now thanks to this composer command. As long as there is a package registered in packagist.org with the ability to setup a project with dependencies of any kind you can just tell composer to ready it for you. The example could be a silex application:
composer create-project fabpot/silex-skeleton
Thankfully @fabpot took the job to create a sample project skeleton for silex. Let’s remember that one thing is the framework or microframework and another different is the folders, organization, bootstrap files, that carry along with a proper application using those frameworks. For the case of symfony, don’t worry guys, we have know it all along just we did not look hard enough:
composer create-project symfony/framework-standard-edition
You really name it, as long as there was someone careful enough to prepare a bootstrapped skeleton for that particular lib or framework you love, there will be an easy 1 punch setup.
Furthermore, if you were looking for a particular version you can do:
composer create-project symfony/framework-standard-edition sf21beta1Dir v2.1.0-BETA1
If you want to go straight to the source you could do right on the same directory bootstrap in a php-flow subdirectory the project Bergie’s nice project PHPFlow like this:
composer create-project PhpFlo/PhpFlo php-flow --dev --prefer-source
Note: If create-project uses a source install, you generally want to delete the .git folder and init a clean git repo for your project. (thanks @stof)
Finally, it is in the responsibility of the package maintainer to work on composer post install hooks. This is the information that will make the development faster and easier. Using those post install scripts is not exactly easy but it can be done. This will benefit anyone coming and just doing work on a completely setup environment!
If you enjoy this blog post please consider donating. I am fund raising 1,800$ for my ticket to SymfonyLive 2012 in San Francisco.
If you want to help me go there, or would like to meet me, I would love to meet you there and hangout with the community. Please help me get there! Thanks!
I thank the Lord Jesus for His grace so far on learning symfony2 and for the opportunity that is opening to attend my first SymfonyLive event. I am also thankful to KnpLabs, happy developers! for helping me with the conference ticket!
You guys rock!