Composer has become very popular in the past few years, and it's easy to see why. It's made the act of installing and using libraries incredibly simple, and helped with standardising use of namespaces and autoloaders.
There have been proposals in the past to make Moodle itself available as a composer package, but I do not feel that this would be the right fit. Moodle is, after all, the application, it is not the library.
However, I feel that we should be able to use it as a way of installing third-party libraries which we use within Moodle. In order to help people use libraries in a standard way, we should also standardise how it is included.
So my proposal is that we:
- allow core use of the existing composer.json file in /composer.json with installation of packages to /vendor/
- should specify a fixed version of each library, and ensure correct generation of the composer.lock
- modify the Moodle autoloader to make use of the /vendor directory and include its vendor/autoload.php file
- only support use of Composer for core use and not in Plugins at this time.
This will allow us to move the management of many of the third-party libraries to composer.
- Because its' a library world;
- We should be using the clients and libraries available to us;
- We shouldn't be managing their dependencies manually;
- We should make it easy for ourselves to upgrade libraries.