Fork me on GitHub


GitHub Core

Show your support for Zikula! Sign up at Github account and watch the Core project!

GitHub Modules

Forum Activity

Forum feed

» Visit forum | » View latest posts


Articles | Development

Articles: Composer dependency manager

Contributed by drak on Dec 24, 2012 - 11:01 PM


From Zikula Core 1.4 we have started using Composer and I've been asked to explain the reasoning behind this. Composer is a PHP dependency manager that has taken the PHP community by storm. It is vastly superior to PEAR for a number of reasons I will cover in this post.

Until recently, we've always stored vendor libraries directly in the core repository and it's always been a maintenance chore to update vendor libraries. Using Composer, one can just specify the libraries one depends on and it will not only go and download them for you, but it'll update the packages when there are upstream changes (all controllable). What this means for developers is you must manually run the composer command after cloning a repository and when the composer.json manifest is updated.

But that's not all, because there's also which tracks all packages available in Composer (although Composer is not coupled to Packagist). This is great news for library authors because there is immediate exposure to the PHP community. All a library author needs to do is define a composer.json manifest in their Github repository (or any VCS repository for that matter) and then tell Packagist about it. From there on, others can specify your library with just a single line in your project's composer.json manifest.

Where the real magic happens however is they way in which Composer is able to solve dependencies. You might rely on just one vendor library, say "doctrine/doctrine-orm version 2.3.0" - with just that one require, composer will download and manage all the other requirements, like Doctrine Common, Doctrine DBAL, Symfony2 Yaml and Console.

Composer's last piece of magic is it's ability to autoload PSR-0 compliant library, and in fact, most non-compliant libraries also as it generates an autoloader specific to your requirements. Clever stuff!

Next time you get the source version of Zikula Core 1.4, please checkout the for instructions on how to run Composer




Comment by:
Jusuff's Avatar
24 Dec 2012 - 12:45PM
It's probably worth to point that composer is only for developers, who want to work/contribute and will clone github repository.

Those, who don't use Zikula sources from repo (and use simple download or builds from CI), wont meet composer :)
Comment by:
phaidon's Avatar
25 Dec 2012 - 12:44AM
@drak thank you
Comment by:
Kaik's Avatar
13 Feb 2013 - 12:20AM
Composer linked wrong
Hi, Composer word in this article is linked to .com actually composer site is :)
Only logged in users are allowed to comment. register/log in