BoltCM

Sophisticated, Lightweight and Simple

Jump to docs navigation
Edit on GitHub

Howtos » Installing Local Extensions

Bolt supports installation of extensions that are not included on Bolt's extensions site.

There are a couple of caveats:

Note: If your local extension requires libraries from Packagist, simply add them to the composer.json in the root directory of your Bolt install by performing a composer require author/package.

Step 1

Create the directory for you extension in {web_root}/extensions/local/{author_name}/{extension_name}/

Where:

Step 2

Create a composer.json to guarantee autoloading as:

{
    "name": "{author_name}/{extension_name}",
    "description": "A description about your extension should go here.",
    "type": "bolt-extension",
    "require": {
        "bolt/bolt": "^3.0"
    },
    "authors": [
        {
            "name": "Your Name",
            "email": "your@email.com"
        }
    ],
    "autoload": {
        "psr-4": {
            "Bolt\\Extension\\MyName\\MyExtension\\": "src/"
        }
    },
    "extra": {
        "bolt-assets": "web",
        "bolt-class": "Bolt\\Extension\\MyName\\MyExtension\\MyExtensionExtension"
    }
}

Where:

Step 3

Create an src/MyExtensionExtension.php file that contains something like this:

namespace Bolt\Extension\MyName\MyExtension;

use Bolt\Extension\SimpleExtension;

class MyExtensionExtension extends SimpleExtension
{
    // Extension code goes here.
}

Step 4

Bolt might access your public assets (javascripts, stylesheets, images, etc.). For local extension, copy your assets manually to : /{public_root}/extensions/local/{author_name}/{extension_name}/

Where:

Updating/Importing

Many times developers create the extension locally and import changes and updates (e.g. via git pull).

In doing this, the PHP namespace may change, potentially triggering a fatal error because the autoloader does not get updated automatically, for performance reasons.

If this occurs, there are several approaches to fixing this:


Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.
Spotted a typo, or have something to add? Edit this page on GitHub.