search hotlink icon profile hotlink icon

This page explains extensions by building upon the dependencies example. For the complete result of this example, see the GitLab repository. Note that this repository contains content for other examples as well, as the documentation uses a single package for all examples.

On This Page

Metadata

To make the basic example package extendable, modify the content in the production file fusion.json as follows:

                {
    "name": "Package",
    "description": "Basic example package.",
    "id": "valvoid/package",
    "version": "0.1.0",
    "structure": {
        "gitlab.com/valvoid/'fusion/'php": "package/==1.0.0-dev:main",
        "/cache": "cache",
        "/extensions/config": "extension",
        "/dependencies": [
            "valvoid.com/valvoid/fusion/1.0.0"
        ]
    },
    "environment": {
        "php": {
            "version": "8.1.0"
        }
    }
}
            

Extensions File

In your terminal, set the working directory to any directory within the package and execute the following build command again:

                php fusion build
            

Once done, the extensions.php file within the /cache directory will contain the modification:

                // Auto-generated by Fusion package manager. 
// Do not modify.
return [
    "/extensions/config" => [],
];
            

The content of the extensions.php file is for your package to get the extender information. It contains package identifiers as extension group in a top-down order, where the non-nested root package is listed as the lowest entry.

Since a valid extender must be just an existing package, create relative to the package root the extension group directory /extensions/config/valvoid/package and run the build command again:

                php fusion build
            

Now, the file contains a recursive extension:

                // Auto-generated by Fusion package manager. 
// Do not modify.
return [
    "/extensions/config" => [
        1 => "valvoid/package",
    ],
];