Extensions Structure
Maze uses Fusion's out-of-the-box extension implementation to handle routes
files, defined in the fusion.json
metadata as follows:
{
"id": "valvoid/maze",
"structure": {
"/routes": "extension"
}
}
The extension
directory indicator marks /routes
as an
extension point, where subdirectories named after each extender package
identifier are automatically managed by Fusion.
For example, consider a package using Maze as a router with the following
fusion.json
metadata:
{
"id": "extender/package",
"structure": {
"/dependencies": "valvoid.com/valvoid/maze/1.0.0"
}
}
As a result, Maze is added as a dependency at /dependencies/valvoid/maze
and extended at /routes
with the /extender/package
subdirectory, which contains the routes.php
file:
/dependencies
/valvoid/maze/routes
/extender/package
routes.php
Load Order
Package Identifiers
Maze loads the /extender/package
subdirectories in top-down order as
defined in the extensions.php
file, which Fusion automatically generates
in the cache directory. This file contains a sequential array where each
index indicates a package's position in the build or replicate chain:
return [
"/routes" => [
// ordered package identifiers
1 => "extender/package",
3 => "other/extender/package"
]
];
Multiple Files
Within a single /extender/package
, routes files can be organized in
nested subdirectories. Maze loads all files alphabetically.
For example:
- 1.
/any/more_routes.php
- 2.
routes.php
- 3.
whatever_routes.php