DEV Community

Cover image for Introducing Fusion – A PHP Package Manager
Sergej Willmann
Sergej Willmann

Posted on • Edited on

Introducing Fusion – A PHP Package Manager

Fusion is a PHP package manager that manages dependencies, loadable source code, extensions, and state of PHP projects.

Everything Is a Modular Package

The root project, its dependencies, and even Fusion itself are modular packages that can be used as standalone software, as dependencies in other projects, or both at the same time.

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 Hooks

Packages can define custom scripts in their metadata that run after recycling, downloading, installing, or updating, and before migrating or deleting the package.

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.

Project Repository

For the source code, issues, or contribution, see the GitLab repository.

Top comments (0)