1

Topic: Re: Composer & Packagist for htmLawed

Editors note: I had to cripple the contents of the code-blocks to make the forum accept this post. Dummy string {$DOMAIN} refers to the Bioinformatics domain and HTTP scheme in front of it.

---

I really only registered to reply to the Composer & Packagist for htmLawed topic.

Composer seems to have become the de facto package and dependency manager for PHP, and it is too bad none of the PHP Labware utilities are available through it. There is a way to make them available to users that does not require public version control, repackaging old ZIP files, adapting to whatever Packagist wants, or anything else.

You can easily run your own Composer package repository (https://getcomposer.org/doc/05-repositories.md) for PHP Labware utilities. This would require only a single JSON file somewhere at a public URL. In the existing downloads folder would work. Anyone can then add this repository URL to their Composer configuration and start requiring PHP Labware packages.

I was experimenting with this myself and ended up creating the following minimal packages.json-file:

{
  "packages": {
    "phplabware/htmlawed": {
      "1.2.4.1": {
        "name": "phplabware/htmlawed",
        "version": "1.2.4.1",
        "dist": { "url": "{$DOMAIN}/phplabware/downloads/htmLawed1241.zip", "type": "zip" },
        "autoload": { "files": [ "htmLawed.php" ] }
      },
      "1.2.1.1": {
        "name": "phplabware/htmlawed",
        "version": "1.2.1.1",
        "dist": { "url": "{$DOMAIN}/phplabware/downloads/htmLawed1211.zip", "type": "zip" },
        "autoload": { "files": [ "htmLawed.php" ] }
      }
    }
  }
}

If this file was published as {$DOMAIN}/phplabware/downloads/packages.json anyone would be able to use composer within their projects to include htmLawed versions 1.2+ (because I didn’t add any others). Example use, assuming you are in a directory that already has Composer set up:

composer config repositories.phplabware composer {$DOMAIN}/phplabware/downloads/
composer config secure-http false
composer require phplabware/htmlawed

You would be able to auto-generate this packages.json file based on the contents of the downloads folder, meaning you have little to no extra work on top of what you currently do upon a new release.

This is the nice thing about decentralised package managers, you can have everything on your own domain!

2

Re: Re: Composer & Packagist for htmLawed

[Sorry about the delay in responding.]

Thanks for posting this. I have implemented your suggestion. Details on using Composer to install/update htmLawed as a package are at http://www.bioinformatics.org/phplabwar … _usage.htm.