GacelaBuild modular PHP applications
Gacela 2.0 · PHP 8.3+. Split your application into modules that talk through one door. Everything behind it stays private.
Gacela 2.0 · PHP 8.3+. Split your application into modules that talk through one door. Everything behind it stays private.
Core concepts
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.
The entry point of the module, and the only class other modules call.
Factory.phpCreates the module's internal services and wires its intra-dependencies.
Provider.phpResolves what the module needs from outside: its extra-dependencies.
Config.phpReads the project's config files from one predictable place.
Quickstart
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.
use Gacela\Framework\Gacela;
use Module\Facade;
require __DIR__ . '/vendor/autoload.php';
Gacela::bootstrap(__DIR__);
$facade = new Facade();
echo $facade->greet('Alice'); # Hi, Alice!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);
}
}namespace Module;
use Gacela\Framework\AbstractFactory;
use Module\Service\Greeter;
final class Factory extends AbstractFactory
{
public function createGreeter(): Greeter
{
return new Greeter();
}
}namespace Module\Service;
final class Greeter
{
public function greet(string $name): string
{
return "Hi, $name!";
}
}Features
Get started
composer require gacela-project/gacela:^2.0Read the quickstart · Upgrade from 1.21 · See who uses Gacela