cspray / labrador
Core functionality powering Labrador Kennel Applications through Plugins, Events, and Engines
Requires
- php: ^7.2|^8.0
- ext-json: *
- adbario/php-dot-notation: ^2.2
- amphp/amp: ^2.4
- amphp/log: ^1.1
- cspray/labrador-async-event: ^2.3
- cspray/labrador-exceptions: ^1.2
- cspray/yape: ^3.1
- monolog/monolog: ^2.0
- rdlowrey/auryn: ^1.4
Requires (Dev)
- amphp/phpunit-util: ^1.2
- cspray/labrador-coding-standard: ^0.2
- phpunit/phpunit: ~9.1
This package is auto-updated.
Last update: 2024-12-23 06:18:25 UTC
README
An opinionated, asynchronous micro-framework written on top of amphp. Built using SOLID principles, unit testing, and a modular ecosystem Labrador aims to be a production-ready framework for creating asynchronous PHP applications. Labrador Core serves as the foundation for this framework and provides important key concepts for building apps with Labrador.
Installation
Composer is the only supported method for installing Labrador packages.
composer require cspray/labrador
Quick Start
If you'd rather get started quickly without having to read a bunch of documentation the code below demonstrates how to
quickly get an Application
implemented and running. Otherwise, we recommend checking out the Documentation for more
detailed information, and a complete guide to getting started.
<?php // app.php in your project's root directory require_once __DIR__ . '/vendor/autoload.php'; use Cspray\Labrador\AbstractApplication; use Cspray\Labrador\EnvironmentType; use Cspray\Labrador\CoreApplicationObjectGraph; use Cspray\Labrador\Engine; use Cspray\Labrador\StandardEnvironment; use Amp\Promise; use Amp\Delayed; use Amp\Log\StreamHandler; use Auryn\Injector; use Monolog\Logger; use function Amp\call; use function Amp\ByteStream\getStdout; class HelloWorldApplicationObjectGraph extends CoreApplicationObjectGraph { public function wireObjectGraph() : Injector { $injector = parent::wireObjectGraph(); // wire up your app's dependencies return $injector; } } class HelloWorldApplication extends AbstractApplication { protected function doStart() : Promise { return call(function() { yield new Delayed(500); // just to show that we are running on the Loop $this->logger->info('Hello Labrador!'); }); } } $environment = new StandardEnvironment(EnvironmentType::Development()); $logger = new Logger('labrador.hello-world', [new StreamHandler(getStdout())]); $injector = (new HelloWorldApplicationObjectGraph($environment, $logger))->wireObjectGraph(); $app = $injector->make(HelloWorldApplication::class); $engine = $injector->make(Engine::class); $engine->run($app);
Documentation
Labrador packages have thorough documentation in-repo in the docs/
directory. You can also check out the
documentation online at https://labrador-kennel.io/docs/core.
Governance
All Labrador packages adhere to the rules laid out in the Labrador Governance repo