https://github.com/cakephp/plugin-installer
A composer installer for installing CakePHP plugins.
https://github.com/cakephp/plugin-installer
cakephp composer-plugin php
Last synced: 7 months ago
JSON representation
A composer installer for installing CakePHP plugins.
- Host: GitHub
- URL: https://github.com/cakephp/plugin-installer
- Owner: cakephp
- License: other
- Created: 2014-08-25T20:00:51.000Z (over 11 years ago)
- Default Branch: 2.x
- Last Pushed: 2025-01-05T10:49:29.000Z (about 1 year ago)
- Last Synced: 2025-01-05T11:27:51.446Z (about 1 year ago)
- Topics: cakephp, composer-plugin, php
- Language: PHP
- Homepage:
- Size: 158 KB
- Stars: 32
- Watchers: 25
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CakePHP Plugin Installer
[](https://github.com/cakephp/plugin-installer/actions/workflows/ci.yml)
[](https://packagist.org/packages/cakephp/plugin-installer)
[](https://packagist.org/packages/cakephp/plugin-installer/stats)
[](LICENSE)
A composer installer for installing CakePHP plugins.
This installer ensures your application is aware of CakePHP plugins installed
by composer in `vendor/`.
## Usage
Your CakePHP application should already depend on `cakephp/plugin-installer`, if
not in your CakePHP application run:
```
composer require cakephp/plugin-installer:*
```
Your plugins themselves do **not** need to require `cakephp/plugin-installer`. They
only need to specify the `type` in their composer config:
```json
"type": "cakephp-plugin"
```
## Multiple Plugin Paths
If your application uses multiple plugin paths. In addition to configuring your
application settings you will also need to update your `composer.json` to ensure
the generated `cakephp-plugins.php` file is correct:
```
// Define the list of plugin-paths your application uses.
"extra": {
"plugin-paths": ["plugins", "extra_plugins"]
}
```
## Plugin Setup
For the installer to work properly ensure that your plugin's composer config
file has a proper autoload section. Assuming your plugin's namespace is "MyPlugin"
the autoload section would be like:
```json
"autoload": {
"psr-4": {
"MyPlugin\\": "src"
}
}
```
Not strictly necessary for the working of the installer but ideally you would
also have an "autoload-dev" section for loading test files:
```json
"autoload": {
"psr-4": {
"MyPlugin\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"MyPlugin\\Test\\": "tests",
"Cake\\Test\\" : "vendor/cakephp/cakephp/test"
}
}
```
If your top level namespace is a vendor name then your namespace to path mapping
would be like:
```json
"autoload": {
"psr-4": {
"MyVendor\\MyPlugin\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"MyVendor\\MyPlugin\\Test\\": "tests",
"Cake\\Test\\" : "vendor/cakephp/cakephp/test"
}
}
```
## Generating Manually
If you need to generate `cakephp-plugins.php` separately, you can simply run the `dumpautoload` command:
```
composer dumpautoload
```
You cannot use `--no-scripts` with `dumpautoload` or `cakephp-plugins.php` will not generate.
If you don't want to re-generate the entire autoload dump, you can run just the scripts:
```
composer run-script post-autoload-dump
```
Please see [composer documentation](https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-) for details.