|
1 | | -# ProcessWire Composer installers |
| 1 | +# ProcessWire Composer Installer |
2 | 2 |
|
3 | | -This project contains [Composer custom installers](https://getcomposer.org/doc/articles/custom-installers.md) for |
4 | | -ProcessWire CMS/CMF modules and site profiles. |
| 3 | +This project contains [Composer custom installers](https://getcomposer.org/doc/articles/custom-installers.md) for ProcessWire CMS/CMF modules and site profiles. |
| 4 | + |
| 5 | +## What does it do and why do we need it? |
| 6 | + |
| 7 | +By default Composer installs all packages into the /vendor/ directory. This is great for things that support this type of structure, but not so great for projects – such as ProcessWire – that expect things to be in specific location: modules in /site/modules/module-name/, and site profiles generally as the /site/ directory itself, /site-profile-name/ when the system hasn't been installed yet, or before installat/site-subsite-name/ in the case of native multisite support. |
| 8 | + |
| 9 | +ProcessWire Composer Installer currently makes two "corrections" to packages that define it as a dependency in their composer.json files: |
| 10 | + |
| 11 | +- **modules** are installed under `./site/modules/ModuleName/` (module name is read from composer.json and converted to PascalCase) |
| 12 | +- **site profiles** are installed under `./site-profile-name/` (site profile name is read from composer.json and the site- prefix is added automatically if needed) |
| 13 | + |
| 14 | +## Site-specific modules supports |
| 15 | + |
| 16 | +One more thing to note is that modules can be installed either from the root directory of the ProcessWire installation, or from the `/site/` directory itself. Installer will automatically determine which location you're currently in, and adjust paths accordingly. |
| 17 | + |
| 18 | +This way we can install modules on a per-site basis (in the case of multisite), or include Composer based module dependencies with a site profile (which would otherwise require manual modifications to the ProcessWire root directory composer.json file, or at least running `composer require` in the root directory for said dependencies.) |
| 19 | + |
| 20 | +## Alternatively... |
| 21 | + |
| 22 | +There's a very similar project you might've heard of, called `hari/pw-module`. While this project and Hari's ProcessWire module installer are similar, there are a few key differences: |
| 23 | + |
| 24 | +- This project allows you to install both modules *and* site profiles |
| 25 | +- This project allows you to install modules from the /site/ directory |
| 26 | +- This project provides some additional features (and composer.json options) in terms of module and site profile naming, and also includes additional rules for auto-formatting module and site profile directory names |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### For developers installing modules or site profiles |
| 31 | + |
| 32 | +- To add a new module from Packagist, run `composer require vendor-name/module-name` in either ProcessWire root directory, or your /site/ directory. |
| 33 | +- To add a new site profile from Packagist, run `composer require vendor-name/site-profile-name` in the ProcessWire root directory. |
| 34 | + |
| 35 | +*Note that in order for this work, the module or site profile in question has to have `wireframe-framework/processwire-composer-installer` as a dependency. See next section for instructions for module or site profile authors.* |
| 36 | + |
| 37 | +### For module or site profile authors |
| 38 | + |
| 39 | +The usage of this project is rather simple. You just need to a) add `wireframe-framework/processwire-composer-installer` as a dependency to your project by manually modifying the composer.json file or by running `composer require wireframe-framework/processwire-composer-installer` in your module or site profile root directory, and b) define the type of your package (via composer.json) as `pw-module` (for modules) or `pw-site-profile` (for site profiles). |
| 40 | + |
| 41 | +Here's a stripped-down sample composer.json for a module: |
| 42 | + |
| 43 | +``` |
| 44 | +{ |
| 45 | + "name": "vendor-name/module-name", |
| 46 | + "type": "pw-module", |
| 47 | + "require": { |
| 48 | + "wireframe-framework/processwire-composer-installer": "^1.0.0" |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +And here's an equally stripped-down sample composer.json for a site profile: |
| 54 | + |
| 55 | +``` |
| 56 | +{ |
| 57 | + "name": "vendor-name/site-profile-name", |
| 58 | + "type": "pw-site-profile", |
| 59 | + "require": { |
| 60 | + "wireframe-framework/processwire-composer-installer": "^1.0.0" |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +*In order for your modules to be easily installed, you should also add them to Packagist: https://packagist.org/.* |
5 | 66 |
|
6 | 67 | ## Requirements |
7 | 68 |
|
|
0 commit comments