Download the PHP package oasys/core without Composer
On this page you can find all versions of the php package oasys/core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package core
Oasys
Minimal HTTP framework for modern PHP.
Works with any PSR-7 messages, PSR-15 middleware, and PSR-11 container.
- Manual and attribute-based routing
- Controller and method level middleware pipeline
- Exception-to-handler mapping
- Small dependency-free kernel
Installation
Example using PHP-DI container and Guzzle's request/response:
Quick start
public/index.php:
src/Controller/IndexController.php:
Routing
Manual routes
You can register routes manually
You can daisy-chain routes
Route attributes
Alternatively, you can use attributes on controller method
...and auto-wire routes
You can use multiple attributes on a single method
Path aliases
You can create dynamic route using alias by registering its pattern
...and then use placeholder in the path
Middleware
You can use any PSR-15 middleware
Scope
You can apply middleware using MiddlewareAttribute
Class-level attributes apply to all methods; method-level attributes apply only to that action
Parameters
You can supply parameters to the middleware
...and access them in the constructor
Resolution
Middleware is resolved with the first option available:
- An existing container entry
MiddlewareInterfaceinstances are reused when no arguments are supplied- Other callables are treated as factories and receive the middleware arguments
- If the container provides
make(), it is used to autowire the middleware with the supplied arguments - Otherwise the middleware is instantiated directly
Exception handling
Register default handler for any exception thrown during runtime
You can register individual handlers for specific exception types
You can daisy-chain mapping
When resolving a handler, ExceptionMapper will:
- use a handler registered for the exact exception class
- otherwise walk up the inheritance chain and use the first parent class that has a handler
- otherwise fall back to the default handler registered in constructor
Any exception thrown inside controllers or middleware is passed to the handler via request attribute
Summary
- Define controllers returning PSR-7
ResponseInterface - Add routing attributes to methods and auto-wire routes, or register routes manually on
Router - Use
MiddlewareAttributeto attach PSR-15 middleware to controllers and actions - Use
ExceptionMapperto send exceptions to dedicated controllers - Let
Kernelwire everything together and emit the response withKernel::send()
All versions of core with dependencies
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.0 || ^2.0
psr/http-server-middleware Version ^1.0
psr/http-server-handler Version ^1.0