Random thoughts

composer support for processwire modules

I am a huge fan of composer. PW ( ProcessWire) is missing one of the good parts of composer. So here is a new installer to install the 3rd party modules of PW via composer.

If you have created a module for PW, what you need to do is add a composer.json file in your github repo and add it to packagist. An example composer.json is

{
    "name": "vendor/package-name",
    "type": "pw-module",
    "description": "Your module what it does",
    "keywords": [ "keywords", "comma", "seprated"],
    "homepage": "https://github.com/harikt/Assets",
    "license": "BSD-2-Clause",
    "authors": [
        {
            "name": "Assets Contributors",
            "homepage": "https://github.com/harikt/Assets/contributors"
        }
    ],
    "require": {
        "php": ">=5.3.0",
        "hari/pw-module": "~1.0"
    }
}

Note the minimum requirement is PHP 5.3 for composer is 5.3 .

An example of a module that works with this is https://github.com/harikt/Assets ( Move the index.php to any where :-) ). You are read more about Assets from here

Installing modules

How do you install the PW modules and the 3rd party dependencies ? Assuming you are in the PW folder.

First download composer from http://getcomposer.org/download/.

Hope you have composer.phar now.

php composer.phar require vendor/package-name version-name

Will install if the vendor/package-name to site/modules/PackageName. All packages vendor/package-name of "type": "pw-module" will be converted to PackageName.

Example you can try

php composer.phar require hari/assets dev-master

Try the above and see where it is installed. If you are a module maintainer, please add a composer.json to your github module and add it to packagist.

Of-course inspired and modified composer installer from Aura Project for PHP

Thank you. Happy PhPing!

Menu