GacelaBuild modular PHP applications
Split your application into modules that talk through one door. Everything behind it stays private.
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.
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!";
}
}use Gacela\Framework\Gacela;
use Module\Facade;
require __DIR__ . '/vendor/autoload.php';
Gacela::bootstrap(__DIR__);
$facade = new Facade();
echo $facade->greet('Alice'); # Hi, Alice!Features
Get started
composer require gacela-project/gacela