Skip to content

Using composer to install addon modules

Ricky edited this page Feb 21, 2022 · 2 revisions

From January 2020 it is now easier to include your own custom modules into HamletCMS. Using composer, custom modules can be pulled directly into the addon modules directory.

To do this create a composer.json in the root of the custom module like the following:

{
    "name": "vendor/module-name",
    "description": "My custom module for HamletCMS",
    "type": "hamlet-cms-module",
    "require": {},
    "extra": {
        "installer-name": "MyCustomModule"
    },
    "authors": [
        {
            "name": "Your name",
            "email": "[email protected]"
        }
    ]
}

Note the type attribute is set to hamlet-cms-module - this is what enables the module to be installed under app/modules/addon rather than the vendor folder. The extra.installer-name property should be the name of your module- it is be practice that this is letters only, with each word capitialised (e.g. MyCustomModule).

If your package is accessible through composer then simply just composer require vendor/repo, if not simply add the vcs link into your project composer.json.

{
  "name": "rbwebdesigns/hamlet-cms",
  "description": "PHP Blog content management system, using a modular MVC framework with Smarty templates",
  "repositories":
  [
    {
      "type": "vcs",
      "url": "https://github.com/rbertram90/core"
    },
    {
      "type": "vcs",
      "url": "https://github.com/vendor/project"
    }
  ],
  "require": {
    ...
    "vendor/package": "version"
  }
}

(See: https://getcomposer.org/doc/04-schema.md#repositories)

Clone this wiki locally