Using Composer with FuelPHP 1.xNovember 1, 2012
The PHP community has come a long way in the past several months; Composer is on the rise and people are loving the ability to mix and match components from other frameworks into their personal favorite.
My personal favorite PHP framework is currently FuelPHP. Fuelphp 2.0 will support composer out of the box but what about those of us with apps running 1.x? Well you are in luck because installing composer and making it work for FuelPHP 1.x is dead simple.
1) Install composer in your project. If you don’t know how to install the composer executable look here.
2) Create yourself a composer.json file for your project. This will allow you to specify dependencies (packages) to be downloaded to your project. You can check out my example composer.json file below.
3) Run “php ./composer.phar install” to install all of the required packages you specified in the last step. These packages will install to fuel/vendor unless you change the path from my example.
4) The final step is the easiest but most important. Add the following line into fuel/app/bootstrap.php after the “Autoload::register()” call.
And Thats It!
You should now be able to call the composer classes directly from your application. Keep in mind that most composer classes follow PSR-0 & PSR-1 which dictate the use of namespaces for directories instead of the common fuelphp convention of using undersores (example: \ImagePackage\Type\Gif vs ImagePackage_Type_Gif)
####If you have any questions or issues just post in the comments. You can also checkout #fuelphp on irc.freenode.net for general fuelphp help!
blog comments powered by Disqus