Articles in this series

  • Composer with Magento

Author - Vinai Kopp

I am a passionate Web Developer and open source enthusiast since 1998. Today my main focus in on Training Developers how to customize Magento.
Since March 2008 I have specialized on the Magento platform, which, at the time, still was in the later Beta stages.
Working as a freelancer for my own clients and in large teams I was able to gather valuable experience in projects ranging from very small to quite large.
This enabled me to move into training Developers how to effectively customize Magento.
Since then I have spent thousands of hours giving trainings, both in-house and open to everybody, in all aspects of the Magento platform.

Since March 2010 I also am a Instructor for the official Magento U developer trainings for Magento.
I spent two years as an employed trainer for Magento, but decided I prefer the freedom to focus on projects I choses myself, and now work as a freelancer again since
January 2014.
I am a member of the Magento Certification Advisory Board and was one of the first to pass the MCD+ exam.
Also, I am an co-author of the German Magento Developer Handbook published by O'Reilly in 2010.

More Info » Follow me on Twitter »

Reader Comments (21)

  1. Luis Tineo
    January 29, 2013 at 5:37 pm /

    Vinai,

    This is awesome – easy to read and follow

    Thanks for sharing it

    Regards,

    Luis

    Reply
  2. Alex
    January 29, 2013 at 10:11 pm /

    Nice article Vinai!
    As composer seems to become the new de-facto standard for package-management within the PHP world, I couldn’t wait for this to reach the Magento-hemisphere :)

    Cheers,
    Alex

    Reply
  3. Andreas von Studnitz
    January 29, 2013 at 11:52 pm /

    Great post, thank you! Looking forward to try that in practice (on Windows… which does support symlinks, but not the way Linux/MacOS does :-) )

    Reply
  4. Matthias
    February 2, 2013 at 7:10 pm /

    Hi Vinai,
    thanks to you I finally tried composer!

    A few things I had to change to make it work on my Debian test system:

    * replace “curl –O http://getcomposer.org/composer.phar” with “curl -s https://getcomposer.org/installer | php”
    * composer.json: replace line
    “twig/twig”:”v1.11.2″
    with
    “twig/twig”:”v1.12.1″,
    (v1.11.2 doesn’t exist, trailing comma missing)
    * composer.json: replace line
    “fbrnc/aoe_templatehints”:”dev-master”,
    with
    “fbrnc/aoe_templatehints”:”dev-master”
    (remove trailing comma)

    Reply
  5. Matthias
    February 2, 2013 at 8:40 pm /

    One more note:
    “n98/magerun”:”*”
    will install a pretty old version of n98-magerun (1.28.0).
    Replace this with
    “n98/magerun”:”dev-master”
    and you get the current version from GitHub (1.51.1 as of now).

    Reply
  6. Volodymyr Dubyna
    Volodymyr Dubyna
    February 5, 2013 at 2:28 pm /

    That is not so easy to use when you try to make a real package manager like packagist.org
    Sure, satis is really simple and easy to start but after half year usage I’ve faced with lot of problems, like: how to update information by commit?
    So, now I’m using https://github.com/composer/packagist
    But for the quick start – Satis is what you need. And thanx author for the great job.
    Composer should be a standard for php libs/extensions/modules/applications.

    Reply
  7. Yevgeniy V.
    February 6, 2013 at 2:03 am /

    Vinai, sorry, I don’t know how much you’re worked with PEAR, but the assumption the PEAR was build with assumption, that PHP library components would be installed system-wide isn’t quite right, at least according my experience. The PEAR is pretty flexible and configurable, even the version that was included with previous versions of magento was smart enought to not interfere with system wide extensions.

    Composer has quite different purpose: “Composer solves the PHP code-sharing problem”, worth reading: http://bergie.iki.fi/blog/composer_solves_the_php_code-sharing_problem/

    In other words “magento-deploystrategy”:”copy” is anti-composer concept which demonstrating the root problem of magento ;) IMHO, it’s time to refactor magento stack to support self containing extensions for easiest distribution and sharing.

    Reply
  8. Artjom Kurapov
    February 13, 2013 at 9:05 pm /

    Could not parse version constraint v1.11.2.*: Invalid version string “v1.11.2.*”

    Reply
  9. Kalen
    Kalen
    February 14, 2013 at 8:58 am /

    Thanks Vinai! This is amazing, I love it. Love that it has an uninstall as well. #thisisgonnachangeverything

    Reply
  10. Josh Ribakoff
    May 26, 2013 at 12:30 pm /

    My extension is ported to multiple shopping carts, so there is a “core library” that is common to all extensions. That core library which depends on zend framework, and it has it’s own composer.json which includes ZF.

    I was getting errors:
    PHP Fatal error: Cannot redeclare class Zend_Controller_Request_Http in magento/lib/Zend/Controller/Request/Http.php on line 1066

    The fix for this was to change the order of my include paths in a bootstrap file for my extension:

    set_include_path(
    PATH_SEPARATOR . MAGE_PATH . ‘/lib/’
    . PATH_SEPARATOR . get_include_path()
    );

    This ensures that composer’s paths come after Magento’s lib folder, so Magento’s lib folder takes precedence.

    It seems like the reason this hack is needed, is because the ZF that composer installs has the require_once, whereas Magento stripped them out for performance reasons. When the require_once are hit, they are ambiguous because of the multiple instances of ZF on the include path.

    Reply
  11. Composer with Magento
    July 29, 2013 at 4:30 pm /

    [...] Magebase VN:F [1.9.22_1171]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.22_1171]Rating: 0 (from 0 votes)Google+ Filed Under: Magento plugins · Tagged With: Composer, Magento [...]

  12. Pete
    Pete
    March 13, 2014 at 6:32 am /

    HI Vinai,

    Really useful article, I started using composer in all projects and it’s a real time saver. I have 1 question.

    Can i map from the local composer.json file where a module installs its files, for example rather than each module i install with composer putting its theme files in base/default can i set it to mynewtheme/default ?

    Thanks in advance.

    Reply
  13. Product Import with Magento | integer_net GmbH / EN

    [...] and loads the necessary import module with the Magento-Composer-Installer. It is controlled via command line and it gives as a result the measured import [...]

Add a Comment & Join the Discussion

Insert small snippets of code by using [code]{your_code_here}[/code]
For larger code blocks please use http://pastebin.com and paste your link.

You may also use the following HTML in your comment: <a href="" title=""> <abbr title="">
<acronym title=""> <blockquote cite=""> <cite> <em> <strike> <strong>