Engine23

Composer and Magento PSR-0 PSR-4 Autoloading

Alright, so your a modern PHP developer and know that most framework updates are adding composer support out of the box, or are already using it.  Sadly every time you develop in Magento you miss it and Magento’s 2.0 release with composer support is still a ways off. Well you’re in luck! Everyone give Mr. Damian Luszczymak a big hug for making an extension that adds composer support to Magento 1.0.  It adds the composer autoloader prior to Magento’s, so if there are ever any conflicts Magento’s should overwrite them.  Also, he did a great job of implementing it via an observer, so we shouldn’t have upgrade issues.

 

Alright, lets get down to it.  

1) Download the extension at https://github.com/magento-hackathon/Magento-PSR-0-Autoloader and install the files.

2) Add  <composer_vendor_path><![CDATA[{{root_dir}}/vendor]]></composer_vendor_path> to your main local.xml under global

3) Create a vendor folder in the Magento root folder

4) Install composer if you haven’t: https://getcomposer.org/

5) If you have composer installed as a global you can now go to the root Magento folder via command line and run "composer init" with defaults and "composer update".

 

That was very simple, and it works great!

Share: