Fusion is a PHP package manager that manages dependencies, loadable source code, extensions, and state of PHP projects.
Everything Is a Modular Package
To keep things simple and easy to use, Fusion handles everything, including your project, its dependencies, and even the package manager itself, as a modular package that can be standalone, a nested dependency of another, or both at the same time. This is possible since each package has its own custom directory structure, which you can define in the metadata file as you like.
Scoped Metadata and Snapshot Files
A package can be defined using three individual metadata files, each serving a different use case:
- Optional local development metadata specific to your personal machine.
- Optional shared development metadata used across all machines in the project.
- Production metadata used for releases.
These files intersect in a top-down order, where local metadata overrides shared metadata, and shared metadata overrides production metadata. Fusion also generates a snapshot file for each metadata file, capturing replicable versions of its dependencies.
Lifecycle Callbacks
Each time Fusion builds a new version, it looks for adaptive packages that need to be notified about the change. To make your package this type, add lifecycle callbacks in your metadata at the key stages:
- After the package is recycled, downloaded, installed, or updated.
- Before the package is migrated or deleted.
Loadable Code
All object-oriented and procedural code is automatically indexed into granular files for custom loading. The same files also form the basis of a pre-built autoloader, providing default out-of-the-box loading.
Flexible Package References
Fusion offers full support for semantic versioning, as well as commit, branch, and tag offsets, which can be extended by intuitive, well-known logic for complex references, similar to the syntax used in code:
- Logical
&&and||operators. - Comparison signs
!=,==,>=,<=,>and<. - Grouping brackets
().
The resolution process uses a conflict-driven clause learning (CDCL) algorithm to ensure efficient decision-making.
Directory Type Indicators
Fusion builds new versions efficiently by recycling existing packages. To instruct the package manager that your package includes a mutable directory built by a callback and should be handled individually as new content, set the mutable indicator in your metadata.
To allow other packages to extend yours at a special directory using the default built-in, out-of-the-box behavior, set the extendable indicator in your metadata. Fusion will also generate an extensions file for your package, containing the parent package dirs and the order in which they extend it, in case your package needs to know this.
Interface-Based Customization
As mentioned above, Fusion is itself a package, and its architecture supports out-of-the-box customization through built-in directory indicators. You can build your own package manager on top by extending it with custom implementations, such as:
- Adding a custom package registry.
- Replacing the download, build, or replication logic.
- Setting a custom log serializer.