CakePHP Plugin Installer
A Composer plugin that makes your CakePHP application aware of plugins installed into vendor/.
Repository Health
Technical Analysis
CakePHP Plugin Installer is a Composer plugin that hooks into Composer’s autoload lifecycle so that CakePHP plugins installed via Composer are automatically registered with your application. Whenever composer install, update, or dumpautoload runs, it generates a cakephp-plugins.php manifest that maps each plugin package to its location on disk, and it injects PSR-4 autoload entries for any app-local plugins found under your configured plugin paths.
The result is that CakePHP can load Composer-managed and application plugins uniformly without any manual bootstrap wiring. Plugin authors only need to declare "type": "cakephp-plugin" in their composer.json, and applications can define multiple plugin paths through the extra.plugin-paths key.
What You Get
- Automatic generation of a
cakephp-plugins.phpmanifest mapping every installed plugin to its path - Custom Composer installer for the
cakephp-pluginpackage type - PSR-4 autoload registration for application-local plugins discovered under configured plugin paths
- Support for multiple plugin directories via the
extra.plugin-pathsconfiguration key - Manual regeneration through
composer dumpautoloador thepost-autoload-dumpscript
Common Use Cases
- Installing third-party CakePHP plugins from Packagist and having them discovered without extra configuration
- Structuring a CakePHP application with local plugins that autoload from a
plugins/directory - Organizing large applications across several plugin paths that all need consistent autoloading
Under The Hood
Architecture — The package is a single Cake\Composer\Plugin class in src/Plugin.php implementing Composer’s PluginInterface and EventSubscriberInterface. It subscribes to the pre-autoload-dump and post-autoload-dump events: the pre-dump handler scans each configured plugin path (defaulting to plugins), discovers app plugins via a DirectoryIterator, and adds PSR-4 autoload/dev-autoload namespace-to-path entries onto the root package; the post-dump handler writes the generated cakephp-plugins.php manifest mapping every cakephp-plugin package to its resolved directory. Paths are normalized to be relative to the application root so the manifest stays portable.
Tech Stack — Pure PHP targeting php >=8.1 with composer-plugin-api ^2.0 as its only runtime dependency. Development tooling includes PHPUnit (10–13), the CakePHP CodeSniffer ruleset (phpcs), and PHPStan for static analysis, all wired through composer scripts.
Code Quality — The codebase uses declare(strict_types=1), typed signatures, and interface-driven design. It ships a PluginTest test case under tests/TestCase/, a phpunit.xml.dist, a phpcs config, and a phpstan.neon, indicating consistent linting and static-analysis enforcement despite the small surface area.
API Design — There is effectively no public API to call; integration is declarative. Plugin authors set "type": "cakephp-plugin" and applications optionally set extra.plugin-paths, after which everything happens transparently during Composer runs. This zero-boilerplate contract keeps the developer experience minimal and hard to misuse.