decodelabs / fabric
Lightweight PHP framework implementation using DecodeLabs ecosystem
Requires
- php: ^8.1
- decodelabs/archetype: ^0.3
- decodelabs/clip: ^0.3.8
- decodelabs/coercion: ^0.2.7
- decodelabs/dovetail: ^0.2
- decodelabs/exceptional: ^0.4.4
- decodelabs/genesis: ^0.9
- decodelabs/glitch: ^0.18.9
- decodelabs/greenleaf: ^0.3
- decodelabs/harvest: ^0.3
- decodelabs/lucid: ^0.4.7
- decodelabs/systemic: ^0.11.9
- decodelabs/veneer: ^0.11.6
Requires (Dev)
- decodelabs/phpstan-decodelabs: ^0.6.7
- decodelabs/stash: ^0.5.6
README
Lightweight PHP framework implementation using DecodeLabs ecosystem
Fabric provides the structures, prerequisites and conventions for building a web application using the DecodeLabs ecosystem.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/fabric
Usage
A Fabric app looks very similar to a standard package with most code residing in the src folder, under a namespace of your choice and loaded via composer.
It does not require a custom entry point as it will automatically detect and load the app when the framework is initialised via the built in Bootstrap:
# Example nginx config server { listen 443 ssl; server_name my-app.localtest.me; root /var/www/my-app/; # Rewrite to fabric Bootstrap rewrite .* /vendor/decodelabs/fabric/src/Bootstrap.php last; include snippets/php81.conf; include snippets/ssl.conf; }
Config
Fabric utilises Dovetail
for config loading - via a private .env file in the app root and data files in /config (though this can be customised if necessary).
The most important config file is the Environment.php
file which defines some key values for the rest of the app to initialize with.
The appNamespace value will allow you to define the namespace in which the majority of your app code will reside, and which is already defined for loading in your composer file.
App file
The App file is the main entry point for your app and is where you can override default behaviour in key areas of your app. If one is not defined, a default will be used.
While in early development, the interface for this class will change a lot, however default implementations will be provided in the Generic instance of the interface to ensure backwards compatibility.
The App instance can be recalled using the Fabric Veneer frontage:
use DecodeLabs\Fabric; $app = Fabric::getApp();
Structure
Fabric provides solid HTTP and CLI kernels that can handle requests in both contexts. Clip
is used for CLI tasks, and Harvest
for HTTP.
The HTTP kernel uses an extensible set of Middlewares to provide a flexible request handling pipeline. The default implementation is provided by Harvest
and is a good starting point for most apps.
Greenleaf is used for routing and provides a simple, flexible and powerful routing system for HTTP Actions.
Licensing
Fabric is licensed under the MIT License. See LICENSE for the full license text.