A package can be described by up to three environment-specific metadata files in its root directory. In addition to separating metadata by environment, these files can override each other's entries when Fusion merges them in top-down order as follows:
Note
To illustrate metadata, we use the Box - PHP DI Container package.
Local Metadata File
The optional fusion.local.php file is a requireable PHP script that returns
a metadata array affecting local development (specific to your development
machine):
return [
// override production name
"name" => "Custom Box",
// override shared info
"description" => "My PHP DI Container."
];
Remember to ignore this file in your version control system and never commit it to the project repository, as it overrides entries from other metadata files where they intersect and has the following limitations:
- No static production entries:
- The
idprimitive - The
statefuldirectory
- The
- No nested dependencies overlapping with other metadata files
- Nullable self-dependency
Note
When building a standalone package, you can add a self-dependency for
convenient recursive updates, so the user does not have to specify the source
manually each time. In local or shared development, this source can be reset
by setting it to null, allowing the package to be built in the current
environment instead of being overridden by the linked production version.
Shared Metadata File
The optional fusion.dev.php file is a requireable PHP script that returns
a metadata array affecting shared development (applies to all development
machines in the project):
return [
// override production info
"description" => "Shared PHP DI Container."
];
Remember to commit this file to the project repository, but exclude it from archive exports in your version control system, as it overrides entries from production metadata files where they intersect and has the following limitations:
- No static production entries:
- The
idprimitive - The
statefuldirectory
- The
- No nested dependencies overlapping with other metadata files
- Nullable self-dependency
Production Metadata File
The required fusion.json file is an independent JSON dataset that represents
the production metadata. Unlike the other metadata files,
it must always be committed and included in archive exports, and it contains
at least the following entries:
- All the primitives
- The required environment
- The
statefuldirectory
{
"name": "Box",
"description": "A PHP DI Container.",
"id": "valvoid/box",
"version": "1.0.1",
"structure": {
"/state": "stateful"
},
"environment": {
"php": {
"version": "8.1.0"
}
}
}