Core concepts
The anatomy of a module
Every module exposes the same four classes, so any module in any Gacela project reads the same way. Other modules only ever call the Facade.
Facade.php
Facade
The entry point of the module, and the only class other modules call.
Factory.phpFactory
Creates the module's internal services and wires its intra-dependencies.
Provider.phpProvider
Resolves what the module needs from outside: its extra-dependencies.
Config.phpConfig
Reads the project's config files from one predictable place.
Quickstart
A module in three files
This is the whole ceremony: a Facade in front, a Factory wiring a service behind it, and one bootstrap call at your entry point. The Facade resolves its sibling Factory automatically.
php
use Gacela\Framework\Gacela;
use Module\Facade;
require __DIR__ . '/vendor/autoload.php';
Gacela::bootstrap(__DIR__);
$facade = new Facade();
echo $facade->greet('Alice'); # Hi, Alice!php
namespace Module;
use Gacela\Framework\AbstractFacade;
/**
* @method Factory getFactory()
*/
final class Facade extends AbstractFacade
{
public function greet(string $name): string
{
return $this->getFactory()
->createGreeter()
->greet($name);
}
}php
namespace Module;
use Gacela\Framework\AbstractFactory;
use Module\Service\Greeter;
final class Factory extends AbstractFactory
{
public function createGreeter(): Greeter
{
return new Greeter();
}
}php
namespace Module\Service;
final class Greeter
{
public function greet(string $name): string
{
return "Hi, $name!";
}
}Features
Beyond the basics
Container DIBindings, tags, hooks, definitions, scopes & lazy servicesCachingThree layers: framework resolution, cacheable methods, file cacheToolingcache:warm, doctor, debug:module, debug:graph, profile:reportLifecycle eventsZero-cost bootstrap, config, container & cache events for tracingHealth checksPer-module status for the doctor CLI and HTTP endpointsInject attribute#[Inject] on constructors, properties and settersProvides attributeDeclarative #[Provides] for provider service registrationTestingGacelaTestCase: bootstrap isolation and event-backed assertions
Get started
Start your first module
bash
composer require gacela-project/gacela:^2.0Read the quickstart · Upgrade from 1.21 · See who uses Gacela