Since Fusion itself is an extendable package, you can create your own package manager on top by using it as a dependency and extending it through its built-in extension logic.
Note
For simplicity, this example omits common version control steps and assumes you know how to manage a project with your version control system. We focus solely on creating an easy-to-follow development build of a custom package manager on top of Fusion, which you would later commit to your repository.
Production Metadata
Like any project, we start by creating the fusion.json file in an empty
directory of your choice with the following dummy content:
{
"name": "Package",
"description": "Custom package manager.",
"id": "valvoid/package",
"version": "0.1.0",
"structure": {
"/config": ":valvoid/fusion/extensions/config",
"/dependencies": "valvoid.com/valvoid/fusion/2.0.0",
"/state": "stateful"
},
"environment": {
"php": {
"version": "8.2.0"
}
}
}
Beyond the required basic entries, our metadata declares Fusion as a
nested dependency and maps the
extendable configuration path
to our local config path. For this example page, we leave the path as
abstract in the metadata and run the
build command
from the project directory:
fusion build
Note
We did not create the config directory here for simplicity, since we do
not run any configured commands from the nested Fusion. Otherwise, the
directory would need to exist.
Once done, the project directory now includes the downloaded Fusion package with
the generated extensions.php file in the state directory (other files not
shown here for simplicity):
dependenciesvalvoid/fusion: Nested Fusion packagestate/extensions.php: Built-in extension
fusion.json
This file is where the built-in extension logic records the mapped directories as a persistence layer. In our example, it contains the following simplified content:
return [
"/extensions/config" => [
1 => "<our project absolute dir>/config",
]
];
Now, when loading the configuration, Fusion reads our mapped config
directory on top of its own
default files,
allowing us to extend or completely override them.
User-Wide Terminal Interaction
Fusion isolates the user scoped config, state, and cache paths using the
root package identifier, which you can list with the
-p option:
fusion -p
For the system-wide standalone version we currently use, these paths end
with the case-insensitive valvoid/fusion segments. Running the nested
version in our example from its root directory shows paths ending with
valvoid/package segments:
php ./dependencies/valvoid/fusion/fusion -p
Due to this separation, we can run our in-development package manager
alongside the system-wide Fusion installation without conflicts. Since
the system already has the default fusion executable, we link our user-wide
version as custom-fusion:
dependenciesvalvoid/fusion: Nested Fusion packagefusion: CLI file we link
Linux Commands
Ensure the user-wide binary directory exists:
mkdir -p $HOME/.local/bin
If the directory was just created, reload your profile in the current
session (or log out and back in) to add it to the PATH:
source $HOME/.profile
From the project root, link Fusion's CLI file to the user-wide binary directory:
ln -s $PWD/dependencies/valvoid/fusion/fusion $HOME/.local/bin/custom-fusion
Make the link executable:
chmod +x $HOME/.local/bin/custom-fusion
Verify the installation:
custom-fusion -v
macOS Commands
Ensure the user-wide binary directory exists:
mkdir -p $HOME/.local/bin
Add it to the PATH variable if not already present:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zprofile
If the directory was just created, reload your profile in the current
session (or log out and back in) to add it to the PATH:
source $HOME/.zprofile
From the project root, link Fusion's CLI file to the user-wide binary directory:
ln -s $PWD/dependencies/valvoid/fusion/fusion $HOME/.local/bin/custom-fusion
Make the link executable:
chmod +x $HOME/.local/bin/custom-fusion
Verify the installation:
custom-fusion -v
Windows Commands
Ensure the user-wide binary directory exists:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\bin"
From the project root, create a launcher batch file pointing to the CLI file:
Set-Content "$env:USERPROFILE\bin\custom-fusion.bat" `
-Value '@php "%CD%\dependencies\valvoid\fusion\fusion" %*'
Add the binary directory to your PATH variable (takes effect in new
sessions) and restart PowerShell or open a new session to load it:
setx PATH "$env:USERPROFILE\bin;$env:PATH"
Verify the installation:
custom-fusion -v