labrador-kennel / framework
A framework for building asynchronous applications with Amp and Annotated Container.
Requires
- php: ^8.2
- ext-json: *
- ext-pcntl: *
- amphp/cache: ^v2.0.0
- amphp/http: ^v2.1
- amphp/http-server: ^v3.0
- amphp/http-server-session: ^v3.0
- amphp/http-server-static-content: ^2.0
- amphp/log: ^v2.0
- cspray/annotated-container: ^v3.0
- cspray/marked-logs: ^2.0
- labrador-kennel/async-event: ^4.0
- labrador-kennel/async-event-autowire: ^3.0
- league/plates: ^3.6
- league/uri: ^7
- league/uri-components: ^7
- monolog/monolog: ^3
- nikic/fast-route: ^1.3
- ocramius/package-versions: ^2.7
- php-di/php-di: ^v7.0
- psr/clock: ^1.0
- ramsey/uuid: ^4.4
- respect/validation: ^2.2
Requires (Dev)
- amphp/http-client: ^v5.0
- cspray/labrador-coding-standard: 0.1.0
- cspray/stream-buffer-intercept: ^0.1.0
- mikey179/vfsstream: ^1.6
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11
- psalm/phar: ^5.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-07-20 13:03:37 UTC
README
Labrador is still in heavy development. A 1.0.0-alpha release is near but the API is still highly volatile and subject to change!
Labrador is a microframework built on-top of Amphp and Annotated Container. It offers a non-traditional way of writing small-to-medium sized applications in PHP. Among its many features includes:
- Everything in pure PHP. Have a fully-featured web server up with
php app.php
- Declarative approach to dependency injection
- Comprehensive, secure solution for handling configuration
- Asynchronous by default
- Robust, data-rich event system for knowing when things happen
- An easy-to-use HTTP and routing layer
If you're looking for a more complete skeleton to get started with writing Labrador-powered apps, you should check out labrador-kennel/web-app; it is a skeleton for a complete app, including Docker setup, database, and templating.
Install
Use Composer to install the library.
composer require labrador-kennel/framework
Requirements
This is a step-by-step guide to the code you'll need to implement to get this framework serving HTTP requests. This is not meant to be a comprehensive guide on how to deploy in production, but how to get up and running on your local machine.
Step 1: Logging
A critical step that MUST be completed, otherwise your application will not start up. To satisfy this requirement you must implement a Labrador\Logging\LoggerFactory
and mark it as a service to be managed by the dependency injection container. Somewhere in your src/
directory, or some other directory that is autoloaded and scaned by Annotated Container, write some code that resembles the following:
<?php declare(strict_types=1); namespace App; use Amp\Log\StreamHandler; use Cspray\AnnotatedContainer\Attribute\Service; use Labrador\Logging\LoggerFactory; use Monolog\Logger; use Monolog\Processor\PsrLogMessageProcessor; use Psr\Log\LoggerInterface; use function Amp\ByteStream\getStdout; #[Service] final class MyLoggerFactory implements LoggerFactory { public function createLogger() : LoggerInterface{ return new Logger( 'my-logger-name', [new StreamHandler(getStdout())], [new PsrLogMessageProcessor()] ); } }
This is a minimal setup that could be applicable if your app is running in a Docker container. It will stream log output to stdout
using Amp-provided mechanisms. It is important to use a Monolog handler provided by Amp, to avoid blocking I/O operations.
Again, this is a highly important step that you MUST complete. If you get an error from your dependency injection container stating that a LoggerFactory
cannot be instantiated, completing this step is your resolution.
TODO: Determine and document precise steps would need to result in a running app