Jump to content

Composer support for ProcessWire


Hari KT
 Share

Recommended Posts

Hi guys,

so I am a huge fan of composer. PW is missing one of the good parts of composer. So here is a new installer to install the 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": "dev-master"
    }
}

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 welcome to read the post at http://harikt.com/blog/2013/11/08/assets-for-processwire/

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

Will install if the vendor/package-name is of type "pw-module" and you have added the "hari/pw-module" in require section.

{
    "name": "vendor/package-name",
    // more stuffs
    "type": "pw-module",
    "require": {
        "php": ">=5.3.0",
        "hari/pw-module": "dev-master"
    }
}

to `site/modules/PackageName` .

php composer.phar require hari/assets

Try the above and see where it is installed.

Please add a composer.json if you are a module maintainer, for there is more things we can do with composer ;) .

  • Like 4
Link to comment
Share on other sites

The need for composer is actually demonstrating a root problem of a cms or cmf :lol:

However Processwire is not just another cms or cmf but more like a cme = content management engine

that lets me make my own self contained modules without the need for software between me and my code.

Link to comment
Share on other sites

Hi,

I have send a PR to https://github.com/ryancramerdesign/ProcessExportProfile/pull/3 .

If you have a private repo or you find a repo which has no composer.json , you can send a PR. And for the current time you can do like below

{
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "ryancramerdesign/process-export-profile",
                "version": "1.0.0",
                "source": {
                    "url": "https://github.com/ryancramerdesign/ProcessExportProfile",
                    "type": "git",
                    "reference": "master"
                },
                "type": "pw-module",
                "require": {
                    "hari/pw-module": "dev-master"
                }
            }
        }
    ],    
    "require": {
        "ryancramerdesign/process-export-profile": "1.0.0"
    }
}

and now you need composer.phar . Hope you have downloaded composer else please get from http://getcomposer.org/download/ and run

php composer.phar update

It will install the ProcessExportProfile module in site/modules/ProcessExportProfile . When you created a patch for the module, you can change the settings in composer.json , so you get that patch also until Ryan merged it or can switch between branches. See http://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

Thank you.

  • Like 3
Link to comment
Share on other sites

  • 6 months later...

Hey guys,

Recently I saw the module https://github.com/owzim/TextformatterParsedown

It keeps the parsedown in the directory. If we could make use of the composer installer via the module I have created it will help people to get up to dated the dependencies than the project maintainer doing the update.

I wish if processwire could make use of the composer functionality in the core.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...