Composer for plugins - markstory/cakephp GitHub Wiki
Composer & Plugins
The current practices around plugin installation could benefit from composer as well. Generally people use one of the following approaches for installing plugins:
- Copy plugins into each application and check them in with the code.
- Git submodules.
Problems with git submodules for plugins
- Git submodules are more pain to maintain than they should be. Keeping plugins up to date can be tedious.
- They don't work if you're not using git.
- Not all libraries can work as submodules (PHPUnit).
- Nesting submodules requires advanced git knowledge.
Use composer for installing plugins
The composer/installers
package already provides an easy way to install CakePHP plugins. This could be adapted to ensure that autoloaders are updated as well, should CakePHP applications use the composer vendor/autoload.php
convention.
The composer.json
format is simple & should be easy for plugin authors to use. Furthermore, it could be included as part of baking a new plugin. In addition the existing composer/installers
approach has full compatibility with installing plugins outside of composer. Lastly, the community has requested for an easy to use plugin installer for a number of years. Building on the composer infrastructure would save a ton of work, and fulfill a need in the community.
Composer would not be the only option
It should be noted that CakePHP doesn't and won't require plugins to be installed with composer. Continuing to use git submodules, or simply include all plugins in an app's source tree. Plugins being handled via composer could omit the Plugin::load()
if they don't require bootstrap or routes to be loaded, as they would be autoloaded by composer's vendor/autoload.php
.