lsr / interfaces
Laser framework core - Interfaces.
Requires
- php: >=8.4
- nyholm/psr7: ^1.8
- psr/http-server-handler: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- lsr/routing: ^0.4.2 || ^0.5
- nyholm/psr7-server: ^1.1
- phpstan/phpstan: ^2
- phpunit/phpunit: ^12
- roave/security-advisories: dev-latest
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-08 14:50:16 UTC
README
lsr/interfaces provides the shared contracts, HTTP factories, enums, DTOs and exceptions used by the LSR framework. Classes are autoloaded under Lsr\, including Lsr\Interfaces, Lsr\Basic and Lsr\Enums.
Requirements
- PHP
>=8.4. psr/http-server-handler^1.0andnyholm/psr7^1.8(installed by Composer).- No PHP extensions are declared directly in this package's manifest.
- Using
Lsr\Basic\NyholmRequestFactoryadditionally requiresnyholm/psr7-serverin the application; this package declares it only as a development dependency.
Installation
composer require lsr/interfaces
Creating a JSON response
require_once __DIR__ . '/vendor/autoload.php'; use Lsr\Basic\NyholmResponseFactory; $factory = new NyholmResponseFactory(); $response = $factory->createJsonResponse(['status' => 'ok'], 200); // $response is a PSR-7 response with Content-Type: application/json. // Pass it to the application's response emitter or request handler.
NyholmResponseFactory implements Lsr\Interfaces\ResponseFactoryInterface, extending the PSR response-factory contract with JSON, full-response and stream helpers. JSON encoding errors throw JsonException; creating a response does not emit it.
NyholmRequestFactory implements the PSR-17 request and server-request factories, creates server requests from PHP globals and processes existing PSR-7 requests through fromPsrRequest(). That processing parses application/json bodies and turns malformed JSON into Lsr\Exceptions\DispatchBreakException with a bad-request response.
Framework contracts
The src/Interfaces directory defines the integration boundaries for requests, controllers, routes, views, authentication, sessions, cookies and runtime configuration. Implement the relevant contract in the consuming application or install the LSR package that supplies it; installing this package alone does not bootstrap an application, session or router.
Development
CI runs on PHP 8.4 and 8.5. Install development dependencies and run the same three checks locally:
composer install --prefer-dist --no-interaction --no-progress composer cs vendor/bin/phpstan analyse --no-progress vendor/bin/phpunit --no-coverage
PHPUnit uses phpunit.xml and exercises JSON response encoding and request-body parsing, including invalid input. PHPStan uses phpstan.neon; nyholm/psr7-server and lsr/routing are installed as development dependencies so request-factory and route-validator types are available without adding a runtime dependency on routing. No external services are needed.
After installing development dependencies, run composer cs to check PHP coding style without changing files and composer cs:fix to apply fixes (composer cbf is an alias). PHP CS Fixer uses .php-cs-fixer.php.
AI coding assistance
See LSR Skills for AI agent skills for working with the LSR framework.
License
Licensed under the MIT License.