Phalcon adr
NOTE
All classes are prefixed with Phalcon
ADR\Application¶
Final Source on GitHub
ADR composition root. Owns (or accepts) a container, exposes a small registration surface that hides the container's definition API, configures the convention router, and handles the request through the ADR flow.
When no container is supplied one is created with the ADR defaults
(AdrProvider) registered. Type-hinted dependencies autowire; only scalar
parameters need to be declared via define().
Phalcon\ADR\Application- implementsPhalcon\Contracts\ADR\Application
Uses Closure · Phalcon\ADR\Container\AdrProvider · Phalcon\ADR\Events\Event · Phalcon\ADR\Exceptions\RouteNotFound · Phalcon\Container\Container · Phalcon\Container\ContainerFactory · Phalcon\Contracts\ADR\Application · Phalcon\Contracts\ADR\Dispatcher · Phalcon\Contracts\ADR\Router\AttributeFilter · Phalcon\Contracts\ADR\Router\Router · Phalcon\Contracts\Events\Manager · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\Request\Bag\AttributeBag · Phalcon\Http\Response · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct( Container $container = null )
public
static
bind(string $interfaceName,string $concrete)
Bind an interface to a concrete class.
public
static
define(string $className,array $parameters = [])
Register a class together with explicit values for its constructor
public
static
extend(string $name,Closure $extender)
Register a post-build extender (decorator) for a service.
public
static
factory(string $name,Closure $factory)
Register a factory closure for a service.
public
Container
getContainer()
Returns the underlying container for definition-level access.
public
ResponseInterface
handle( AttributeRequest $request )
Routes the request, writes the matched attributes onto it, dispatches
public
static
secureWith(string $guard,string $prefix)
Attach a guard (middleware) to every Action under a namespace prefix.
public
static
set(string $name,mixed $definition)
Register a service with a raw definition (class-string, closure or value).
public
static
setActionDirectory( string $actionDirectory )
Set the filesystem root that backs the base namespace.
public
static
setBaseNamespace( string $baseNamespace )
Set the base namespace the convention router derives Actions from.
public
static
setWordSeparator( string $wordSeparator )
Set the single delimiter between words in a path segment.
Properties¶
protected
string
$actionDirectory = ""
protected
string
$baseNamespace = ""
protected
mixed
$container
protected
array<string, string[]>
$middlewareMap = []
protected
string
$wordSeparator = ""
Methods¶
__construct()¶
bind()¶
Bind an interface to a concrete class.
define()¶
Register a class together with explicit values for its constructor
parameters. Type-hinted dependencies autowire; only the supplied
(usually scalar) parameters are declared. Lazy values (e.g.
new Phalcon\Container\Resolver\Lazy\Env(...)) may be passed as values.
extend()¶
Register a post-build extender (decorator) for a service.
factory()¶
Register a factory closure for a service.
getContainer()¶
Returns the underlying container for definition-level access.
handle()¶
Routes the request, writes the matched attributes onto it, dispatches the Action and returns the response. A single try/catch routes any error through the error responder; if that itself fails, a bare 500 is returned so nothing escapes uncaught.
secureWith()¶
Attach a guard (middleware) to every Action under a namespace prefix.
set()¶
Register a service with a raw definition (class-string, closure or value).
setActionDirectory()¶
Set the filesystem root that backs the base namespace.
setBaseNamespace()¶
Set the base namespace the convention router derives Actions from.
setWordSeparator()¶
Set the single delimiter between words in a path segment.
ADR\Container\AdrProvider¶
Class Source on GitHub
Registers the ADR seams in the container; concretes autowire.
Used instead of Phalcon\Container\Provider\Web for ADR applications. It
shares the short aliases (request/response/router/eventsManager) but
binds the ADR contracts behind them.
Phalcon\ADR\Container\AdrProvider- implementsPhalcon\Contracts\Container\Service\Provider
Uses Phalcon\ADR\Dispatcher · Phalcon\ADR\Emitter\SapiEmitter · Phalcon\ADR\Responder\JsonResponder · Phalcon\ADR\Router\AttributeFilter · Phalcon\ADR\Router\Router · Phalcon\Contracts\ADR\Dispatcher · Phalcon\Contracts\ADR\Emitter\Emitter · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Contracts\ADR\Router\AttributeFilter · Phalcon\Contracts\ADR\Router\Router · Phalcon\Contracts\Container\Service\Collection · Phalcon\Contracts\Container\Service\Provider · Phalcon\Contracts\Events\Manager · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Contracts\Logger\Logger · Phalcon\Events\Manager · Phalcon\Html\Escaper · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Html\TagFactory · Phalcon\Http\Request · Phalcon\Http\Response · Phalcon\Http\ResponseInterface · Phalcon\Logger\Adapter\Noop · Phalcon\Logger\Logger
Method Summary¶
Methods¶
provide()¶
ADR\Dispatcher¶
Final Source on GitHub
Resolves the Action (and middleware) through the container, wraps it in the
pipeline and runs it, firing the pipeline:* events. Global middleware is
resolved once and cached; only route middleware resolves per request.
The container resolution is the one deliberate Service Locator: it uses the
resolve-only IocContainer contract, so a container swap is a two-method
adapter. Everything else is constructor-injected.
Phalcon\ADR\Dispatcher- implementsPhalcon\Contracts\ADR\Dispatcher
Uses Phalcon\ADR\Events\Event · Phalcon\ADR\Exceptions\NotAnAction · Phalcon\Contracts\ADR\Action · Phalcon\Contracts\ADR\Dispatcher · Phalcon\Contracts\Container\Ioc\IocContainer · Phalcon\Contracts\Events\Manager · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct(IocContainer $container,Manager $events,array $globalMiddleware = [])
public
ResponseInterface
dispatch(string $actionClass,AttributeRequest $request,array $routeMiddleware = [])
protected
array
resolveAll( array $classes )
protected
array
resolveGlobal()
Properties¶
protected
mixed
$container
protected
mixed
$events
protected
array
$globalMiddleware
protected
array|null
$resolvedGlobal = null
Methods¶
__construct()¶
public function __construct(
IocContainer $container,
Manager $events,
array $globalMiddleware = []
);
dispatch()¶
public function dispatch(
string $actionClass,
AttributeRequest $request,
array $routeMiddleware = []
): ResponseInterface;
resolveAll()¶
resolveGlobal()¶
ADR\Emitter\SapiEmitter¶
Class Source on GitHub
Emits a response through the SAPI (headers + body via Response::send()).
Refuses to emit once headers have already been sent.
Phalcon\ADR\Emitter\SapiEmitter- implementsPhalcon\Contracts\ADR\Emitter\Emitter
Uses Phalcon\ADR\Exceptions\HeadersAlreadySent · Phalcon\Contracts\ADR\Emitter\Emitter · Phalcon\Http\ResponseInterface
Method Summary¶
Methods¶
emit()¶
ADR\ErrorResponder¶
Final Source on GitHub
Turns a thrown exception into a response through the responder chain.
The full diagnostic (class, message, file:line and the exception itself) goes to the log with a correlation reference; the client receives only a generic message plus that same reference, unless debug mode is on. Exceptions are mapped to statuses deterministically: an exact class match first, then the ancestor chain, so map ordering never matters.
Phalcon\ADR\ErrorResponder
Uses Phalcon\ADR\Exceptions\MethodNotAllowed · Phalcon\ADR\Exceptions\RouteNotFound · Phalcon\ADR\Payload\Payload · Phalcon\ADR\Payload\Status · Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Contracts\Logger\Logger · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface · Throwable
Method Summary¶
public
__construct(Responder $chain,Logger $logger,bool $debug = false,array $exceptionMap = [])
public
ResponseInterface
handle(RequestInterface $request,ResponseInterface $response,Throwable $exception)
protected
string
correlationId( RequestInterface $request )
protected
array
defaultMap()
protected
array
details(Throwable $exception,string $ref,string $status = Status::ERROR)
protected
string
reason( string $status )
The message that goes with the status. Reporting Internal Server Error
Properties¶
protected
mixed
$chain
protected
mixed
$debug
protected
array
$exceptionMap
protected
mixed
$logger
Methods¶
__construct()¶
public function __construct(
Responder $chain,
Logger $logger,
bool $debug = false,
array $exceptionMap = []
);
handle()¶
public function handle(
RequestInterface $request,
ResponseInterface $response,
Throwable $exception
): ResponseInterface;
correlationId()¶
defaultMap()¶
details()¶
protected function details(
Throwable $exception,
string $ref,
string $status = Status::ERROR
): array;
reason()¶
The message that goes with the status. Reporting Internal Server Error
next to a 404 tells the client the opposite of what happened.
ADR\EventfulHandler¶
Final Source on GitHub
The terminal handler of the pipeline: fires the adr:* events around the
Action's execution.
Phalcon\ADR\EventfulHandler- implementsPhalcon\Contracts\ADR\Handler
Uses Phalcon\ADR\Events\Event · Phalcon\Contracts\ADR\Action · Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\Events\Manager · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct(Action $action,Manager $events)
public
ResponseInterface
__invoke( AttributeRequest $request )
Properties¶
protected
mixed
$action
protected
mixed
$events
Methods¶
__construct()¶
__invoke()¶
ADR\Events\Event¶
Class Source on GitHub
The ADR event vocabulary, fired through the native events manager.
Phalcon\ADR\Events\Event
Constants¶
string
ADR_AFTER_EXECUTE_ACTION = "adr:afterExecuteAction"
string
ADR_BEFORE_EXECUTE_ACTION = "adr:beforeExecuteAction"
string
APPLICATION_AFTER_HANDLE = "application:afterHandle"
string
APPLICATION_BEFORE_HANDLE = "application:beforeHandle"
string
PIPELINE_AFTER_DISPATCH = "pipeline:afterDispatch"
string
PIPELINE_BEFORE_DISPATCH = "pipeline:beforeDispatch"
ADR\Exceptions\ActionDirectoryNotSet¶
Class Source on GitHub
Thrown when the router is asked to match without an action directory; the convention cannot resolve sub-namespaces without one.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\ActionDirectoryNotSet
Method Summary¶
Methods¶
__construct()¶
ADR\Exceptions\Exception¶
Class Source on GitHub
Generic exception for the ADR component, and the base for every typed ADR exception.
BaseExceptionPhalcon\ADR\Exceptions\Exception- implementsPhalcon\Contracts\ADR\Exceptions\ADRThrowable
Uses Exception · Phalcon\Contracts\ADR\Exceptions\ADRThrowable
ADR\Exceptions\HeadersAlreadySent¶
Class Source on GitHub
Thrown when the emitter is asked to send a response after headers have already been sent.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\HeadersAlreadySent
Method Summary¶
Methods¶
__construct()¶
ADR\Exceptions\MethodNotAllowed¶
Class Source on GitHub
Thrown when a route matches the path but not the request method.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\MethodNotAllowed
Method Summary¶
Methods¶
__construct()¶
ADR\Exceptions\NotAnAction¶
Class Source on GitHub
Thrown when the dispatcher resolves a class that is not an ADR Action.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\NotAnAction
Method Summary¶
Methods¶
__construct()¶
ADR\Exceptions\OutputAlreadySent¶
Class Source on GitHub
Thrown when the emitter is asked to send a response after output has already been sent.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\OutputAlreadySent
Method Summary¶
Methods¶
__construct()¶
ADR\Exceptions\RouteNotFound¶
Class Source on GitHub
Thrown when no route matches the request.
BaseExceptionPhalcon\ADR\Exceptions\ExceptionPhalcon\ADR\Exceptions\RouteNotFound
Method Summary¶
Methods¶
__construct()¶
ADR\Front\AbstractHttpFront¶
Abstract Source on GitHub
Boots a container, builds the Application, handles the request and emits the
response. Userland front controllers override loadEnvironment(),
registerProviders() and optionally getApplication(); bootstrap is
exit((new AppFront(dirname(__DIR__)))->run());.
Phalcon\ADR\Front\AbstractHttpFront- implementsPhalcon\Contracts\Front\FrontController
Uses Phalcon\ADR\Application · Phalcon\ADR\Container\AdrProvider · Phalcon\Container\Container · Phalcon\Contracts\ADR\Application · Phalcon\Contracts\ADR\Emitter\Emitter · Phalcon\Contracts\Front\FrontController · Phalcon\Contracts\Http\AttributeRequest
Method Summary¶
public
__construct( string $projectRoot )
public
Container
boot()
Builds the container, loads the environment and registers the providers,
public
int
run()
protected
Container
buildContainer()
protected
ApplicationInterface
getApplication( Container $container )
Builds the Application the front will hand the request to. Override to
protected
int
handleBootError( \Throwable $exception )
protected
void
loadEnvironment( Container $container )
protected
void
registerProviders( Container $container )
Properties¶
protected
Container|null
$container = null
protected
string
$projectRoot
Methods¶
__construct()¶
boot()¶
Builds the container, loads the environment and registers the providers,
returning the container for consumers that need it before (or instead
of) run(). The container is built once and cached, so calling boot()
and then run() reuses the same instance.
run()¶
buildContainer()¶
getApplication()¶
Builds the Application the front will hand the request to. Override to
configure it (setBaseNamespace()/secureWith()) or to wire a different
Phalcon\Contracts\ADR\Application implementation.
handleBootError()¶
loadEnvironment()¶
registerProviders()¶
ADR\Front\HttpFront¶
Class Source on GitHub
Concrete default HTTP front controller. Boots the ADR provider and runs the
application with the framework defaults; subclass to override
loadEnvironment() or registerProviders().
Phalcon\ADR\Front\AbstractHttpFrontPhalcon\ADR\Front\HttpFront
ADR\Input\Input¶
Class Source on GitHub
Generic, string-keyed input bag for an Action.
fromRequest() merges the request query, parsed body and route attributes
into a single bag (later sources win). Extend it to build a typed, per-domain
input value object: the factories use late static binding, so a subclass's
fromRequest() / fromArray() return that subclass.
Phalcon\ADR\Input\Input
Uses Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\Request\Bag\AttributeBag
Method Summary¶
public
__construct( array $data = [] )
public
static
fromArray( array $data )
public
static
fromRequest( AttributeRequest $request )
public
mixed
get(string $key,mixed $defaultValue = null)
public
bool
has( string $key )
public
array
toArray()
Properties¶
protected
array
$data = []
Methods¶
__construct()¶
fromArray()¶
fromRequest()¶
get()¶
has()¶
toArray()¶
ADR\Middleware\CorsMiddleware¶
Class Source on GitHub
CORS middleware. Inert by default: it emits nothing until an origin allowlist
is configured, and only for requests whose Origin is on it. The allowed
origin is always echoed back explicitly, so credentials are never paired with
a wildcard origin. Preflight OPTIONS requests are answered directly.
Phalcon\ADR\Middleware\CorsMiddleware- implementsPhalcon\Contracts\ADR\Middleware
Uses Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\ADR\Middleware · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\Response · Phalcon\Http\ResponseInterface · Phalcon\Traits\Support\Helper\Arr\GetTrait
Method Summary¶
public
__construct( array $config = [] )
public
ResponseInterface
__invoke(AttributeRequest $request,Handler $next)
protected
void
applyHeaders(ResponseInterface $response,string $origin)
protected
bool
isAllowed( string $origin )
Properties¶
protected
bool
$allowCredentials = false
protected
array
$allowedHeaders
protected
array
$allowedMethods
protected
array
$allowedOrigins
protected
int
$maxAge = 0
Methods¶
__construct()¶
__invoke()¶
applyHeaders()¶
isAllowed()¶
ADR\Middleware\MethodOverrideMiddleware¶
Class Source on GitHub
Thin enabler for the native _method override.
Request::getMethod() already honors X-HTTP-Method-Override and, when the
parameter-override flag is on, the _method field. This middleware only
turns that flag on, and only for a POST request whose _method names a
safe verb (PUT/PATCH/DELETE), so _method cannot spoof an arbitrary
method.
Phalcon\ADR\Middleware\MethodOverrideMiddleware- implementsPhalcon\Contracts\ADR\Middleware
Uses Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\ADR\Middleware · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\ResponseInterface
Method Summary¶
Properties¶
protected
array<int, string>
$allowed = [...]
Methods¶
__invoke()¶
ADR\Middleware\RequestIdMiddleware¶
Class Source on GitHub
Ensures every request carries an X-Request-Id, reusing an incoming one or
generating it, exposing it on the request attributes and the response.
Phalcon\ADR\Middleware\RequestIdMiddleware- implementsPhalcon\Contracts\ADR\Middleware
Uses Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\ADR\Middleware · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\Request\Bag\AttributeBag · Phalcon\Http\ResponseInterface
Method Summary¶
Methods¶
__invoke()¶
ADR\Middleware\TimingMiddleware¶
Class Source on GitHub
Adds an X-Response-Time header measuring how long the rest of the pipeline
took to produce the response.
Phalcon\ADR\Middleware\TimingMiddleware- implementsPhalcon\Contracts\ADR\Middleware
Uses Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\ADR\Middleware · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\ResponseInterface
Method Summary¶
Methods¶
__invoke()¶
ADR\Payload\Payload¶
Class Source on GitHub
Immutable payload produced by the domain layer.
Every with*() method returns a new instance, leaving the receiver
unchanged. Named factories provide a concise way to create a payload for the
commonly used statuses.
Phalcon\ADR\Payload\Payload- implementsPhalcon\Contracts\ADR\Payload\Payload
Uses Phalcon\Contracts\ADR\Payload\Payload · Throwable
Method Summary¶
public
PayloadContract
accepted( mixed $result = null )
Creates a payload with the ACCEPTED status.
public
PayloadContract
authenticated( mixed $result = null )
Creates a payload with the AUTHENTICATED status.
public
PayloadContract
authorized( mixed $result = null )
Creates a payload with the AUTHORIZED status.
public
PayloadContract
created( mixed $result = null )
Creates a payload with the CREATED status.
public
PayloadContract
deleted( mixed $result = null )
Creates a payload with the DELETED status.
public
PayloadContract
error( mixed $messages = null )
Creates a payload with the ERROR status.
public
PayloadContract
forbidden( mixed $messages = null )
Creates a payload with the NOT_AUTHORIZED status (authenticated but
public
PayloadContract
found( mixed $result = null )
Creates a payload with the FOUND status.
public
Throwable|null
getException()
Gets the exception thrown in the domain layer, if any.
public
mixed
getExtras()
Gets the arbitrary extra domain information.
public
mixed
getInput()
Gets the domain input.
public
mixed
getMessages()
Gets the domain messages.
public
mixed
getResult()
Gets the domain result.
public
mixed
getStatus()
Gets the payload status.
public
PayloadContract
invalid( mixed $messages = null )
Creates a payload with the NOT_VALID status.
public
PayloadContract
notAccepted( mixed $messages = null )
Creates a payload with the NOT_ACCEPTED status.
public
PayloadContract
notCreated( mixed $messages = null )
Creates a payload with the NOT_CREATED status.
public
PayloadContract
notDeleted( mixed $messages = null )
Creates a payload with the NOT_DELETED status.
public
PayloadContract
notFound( mixed $messages = null )
Creates a payload with the NOT_FOUND status.
public
PayloadContract
notUpdated( mixed $messages = null )
Creates a payload with the NOT_UPDATED status.
public
PayloadContract
processing( mixed $result = null )
Creates a payload with the PROCESSING status.
public
PayloadContract
success( mixed $result = null )
Creates a payload with the SUCCESS status.
public
PayloadContract
unauthenticated( mixed $messages = null )
Creates a payload with the NOT_AUTHENTICATED status (identity not
public
PayloadContract
updated( mixed $result = null )
Creates a payload with the UPDATED status.
public
PayloadContract
valid( mixed $result = null )
Creates a payload with the VALID status.
public
PayloadContract
withException( Throwable $exception )
Returns a copy of the payload with the given exception.
public
PayloadContract
withExtras( mixed $extras )
Returns a copy of the payload with the given extras.
public
PayloadContract
withInput( mixed $input )
Returns a copy of the payload with the given input.
public
PayloadContract
withMessages( mixed $messages )
Returns a copy of the payload with the given messages.
public
PayloadContract
withResult( mixed $result )
Returns a copy of the payload with the given result.
public
PayloadContract
withStatus( mixed $status )
Returns a copy of the payload with the given status.
Properties¶
protected
Throwable|null
$exception = null
protected
mixed
$extras = null
protected
mixed
$input = null
protected
mixed
$messages = null
protected
mixed
$result = null
protected
mixed
$status = null
Methods¶
accepted()¶
Creates a payload with the ACCEPTED status.
authenticated()¶
Creates a payload with the AUTHENTICATED status.
authorized()¶
Creates a payload with the AUTHORIZED status.
created()¶
Creates a payload with the CREATED status.
deleted()¶
Creates a payload with the DELETED status.
error()¶
Creates a payload with the ERROR status.
forbidden()¶
Creates a payload with the NOT_AUTHORIZED status (authenticated but
not allowed - HTTP 403).
found()¶
Creates a payload with the FOUND status.
getException()¶
Gets the exception thrown in the domain layer, if any.
getExtras()¶
Gets the arbitrary extra domain information.
getInput()¶
Gets the domain input.
getMessages()¶
Gets the domain messages.
getResult()¶
Gets the domain result.
getStatus()¶
Gets the payload status.
invalid()¶
Creates a payload with the NOT_VALID status.
notAccepted()¶
Creates a payload with the NOT_ACCEPTED status.
notCreated()¶
Creates a payload with the NOT_CREATED status.
notDeleted()¶
Creates a payload with the NOT_DELETED status.
notFound()¶
Creates a payload with the NOT_FOUND status.
notUpdated()¶
Creates a payload with the NOT_UPDATED status.
processing()¶
Creates a payload with the PROCESSING status.
success()¶
Creates a payload with the SUCCESS status.
unauthenticated()¶
Creates a payload with the NOT_AUTHENTICATED status (identity not
established - HTTP 401).
updated()¶
Creates a payload with the UPDATED status.
valid()¶
Creates a payload with the VALID status.
withException()¶
Returns a copy of the payload with the given exception.
withExtras()¶
Returns a copy of the payload with the given extras.
withInput()¶
Returns a copy of the payload with the given input.
withMessages()¶
Returns a copy of the payload with the given messages.
withResult()¶
Returns a copy of the payload with the given result.
withStatus()¶
Returns a copy of the payload with the given status.
ADR\Payload\PayloadFactory¶
Class Source on GitHub
Thin, injectable factory mirroring the Payload named factories.
It exists so that payload creation can be registered as a service in the DI container and substituted in tests, rather than calling the static factories directly.
Phalcon\ADR\Payload\PayloadFactory
Uses Phalcon\Contracts\ADR\Payload\Payload
Method Summary¶
public
PayloadInterface
accepted( mixed $result = null )
Creates a payload with the ACCEPTED status.
public
PayloadInterface
authenticated( mixed $result = null )
Creates a payload with the AUTHENTICATED status.
public
PayloadInterface
authorized( mixed $result = null )
Creates a payload with the AUTHORIZED status.
public
PayloadInterface
created( mixed $result = null )
Creates a payload with the CREATED status.
public
PayloadInterface
deleted( mixed $result = null )
Creates a payload with the DELETED status.
public
PayloadInterface
error( mixed $messages = null )
Creates a payload with the ERROR status.
public
PayloadInterface
forbidden( mixed $messages = null )
Creates a payload with the NOT_AUTHORIZED status (HTTP 403).
public
PayloadInterface
found( mixed $result = null )
Creates a payload with the FOUND status.
public
PayloadInterface
invalid( mixed $messages = null )
Creates a payload with the NOT_VALID status.
public
PayloadInterface
notAccepted( mixed $messages = null )
Creates a payload with the NOT_ACCEPTED status.
public
PayloadInterface
notCreated( mixed $messages = null )
Creates a payload with the NOT_CREATED status.
public
PayloadInterface
notDeleted( mixed $messages = null )
Creates a payload with the NOT_DELETED status.
public
PayloadInterface
notFound( mixed $messages = null )
Creates a payload with the NOT_FOUND status.
public
PayloadInterface
notUpdated( mixed $messages = null )
Creates a payload with the NOT_UPDATED status.
public
PayloadInterface
processing( mixed $result = null )
Creates a payload with the PROCESSING status.
public
PayloadInterface
success( mixed $result = null )
Creates a payload with the SUCCESS status.
public
PayloadInterface
unauthenticated( mixed $messages = null )
Creates a payload with the NOT_AUTHENTICATED status (HTTP 401).
public
PayloadInterface
updated( mixed $result = null )
Creates a payload with the UPDATED status.
public
PayloadInterface
valid( mixed $result = null )
Creates a payload with the VALID status.
Methods¶
accepted()¶
Creates a payload with the ACCEPTED status.
authenticated()¶
Creates a payload with the AUTHENTICATED status.
authorized()¶
Creates a payload with the AUTHORIZED status.
created()¶
Creates a payload with the CREATED status.
deleted()¶
Creates a payload with the DELETED status.
error()¶
Creates a payload with the ERROR status.
forbidden()¶
Creates a payload with the NOT_AUTHORIZED status (HTTP 403).
found()¶
Creates a payload with the FOUND status.
invalid()¶
Creates a payload with the NOT_VALID status.
notAccepted()¶
Creates a payload with the NOT_ACCEPTED status.
notCreated()¶
Creates a payload with the NOT_CREATED status.
notDeleted()¶
Creates a payload with the NOT_DELETED status.
notFound()¶
Creates a payload with the NOT_FOUND status.
notUpdated()¶
Creates a payload with the NOT_UPDATED status.
processing()¶
Creates a payload with the PROCESSING status.
success()¶
Creates a payload with the SUCCESS status.
unauthenticated()¶
Creates a payload with the NOT_AUTHENTICATED status (HTTP 401).
updated()¶
Creates a payload with the UPDATED status.
valid()¶
Creates a payload with the VALID status.
ADR\Payload\Status¶
Class Source on GitHub
Holds the status codes for the payload.
The two failure-related statuses are distinct, following the Aura.Payload lineage:
ERRORmeans an exception was raised while the domain layer was running. By convention,Payload::withException()pairs with theERRORstatus.FAILUREmeans the domain layer ran to completion but declined the request (for example, a business rule was not satisfied); no exception was raised.
@see Payload
Phalcon\ADR\Payload\Status
Constants¶
string
ACCEPTED = "ACCEPTED"
string
AUTHENTICATED = "AUTHENTICATED"
string
AUTHORIZED = "AUTHORIZED"
string
CREATED = "CREATED"
string
DELETED = "DELETED"
string
ERROR = "ERROR"
string
FAILURE = "FAILURE"
string
FOUND = "FOUND"
string
METHOD_NOT_ALLOWED = "METHOD_NOT_ALLOWED"
string
NOT_ACCEPTED = "NOT_ACCEPTED"
string
NOT_AUTHENTICATED = "NOT_AUTHENTICATED"
string
NOT_AUTHORIZED = "NOT_AUTHORIZED"
string
NOT_CREATED = "NOT_CREATED"
string
NOT_DELETED = "NOT_DELETED"
string
NOT_FOUND = "NOT_FOUND"
string
NOT_UPDATED = "NOT_UPDATED"
string
NOT_VALID = "NOT_VALID"
string
PROCESSING = "PROCESSING"
string
SUCCESS = "SUCCESS"
string
UPDATED = "UPDATED"
string
VALID = "VALID"
ADR\Pipeline¶
Final Source on GitHub
Self-recursive middleware runner. It is itself a Handler: it carries an index
and hands a new Pipeline (advanced by one) forward as the next handler, so
next is always a real Handler - no anonymous classes or callables.
When the middleware is exhausted it invokes the terminal handler (the Action).
Phalcon\ADR\Pipeline- implementsPhalcon\Contracts\ADR\Handler
Uses Phalcon\Contracts\ADR\Handler · Phalcon\Contracts\Http\AttributeRequest · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct(array $middleware,Handler $terminal,int $index = 0)
public
ResponseInterface
__invoke( AttributeRequest $request )
Properties¶
protected
mixed
$index
protected
array
$middleware
protected
Handler
$terminal
Methods¶
__construct()¶
__invoke()¶
ADR\Responder\AbstractFormattedResponder¶
Abstract Source on GitHub
Base for content-type responders: composes Status, Redirect and Format responders into a chain. Subclasses bind the formatter(s).
Phalcon\ADR\Responder\ChainResponderPhalcon\ADR\Responder\AbstractFormattedResponder
Method Summary¶
Methods¶
__construct()¶
ADR\Responder\ChainResponder¶
Class Source on GitHub
Composes single-purpose responders. Each link receives the request, the response threaded so far, and the payload, and returns the response.
Phalcon\ADR\Responder\ChainResponder- implementsPhalcon\Contracts\ADR\Responder\Responder
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct( array $links = [] )
public
ResponseInterface
__invoke(RequestInterface $request,ResponseInterface $response,Payload $payload)
public
ChainResponder
with( Responder $link )
Properties¶
protected
Responder[]
$links
Methods¶
__construct()¶
__invoke()¶
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
Payload $payload
): ResponseInterface;
with()¶
ADR\Responder\FormatResponder¶
Class Source on GitHub
Negotiates a formatter against the request Accept header and renders the
payload as the response body + content type.
If no formatter accepts the header it falls back to the first (default) formatter, so the content type and body are never left unset.
Phalcon\ADR\Responder\FormatResponder- implementsPhalcon\Contracts\ADR\Responder\Responder
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct( array $formatters = [] )
public
ResponseInterface
__invoke(RequestInterface $request,ResponseInterface $response,Payload $payload)
Properties¶
protected
array
$formatters
Methods¶
__construct()¶
__invoke()¶
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
Payload $payload
): ResponseInterface;
ADR\Responder\Formatter\JsonFormatter¶
Class Source on GitHub
Renders a payload as JSON.
Phalcon\ADR\Responder\Formatter\JsonFormatter- implementsPhalcon\Contracts\ADR\Responder\Formatter\Formatter
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Formatter\Formatter
Method Summary¶
public
bool
accepts( string $acceptHeader )
public
string
contentType()
public
string
format( Payload $payload )
Methods¶
accepts()¶
contentType()¶
format()¶
ADR\Responder\Formatter\TextFormatter¶
Class Source on GitHub
Renders a payload as plain text.
Phalcon\ADR\Responder\Formatter\TextFormatter- implementsPhalcon\Contracts\ADR\Responder\Formatter\Formatter
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Formatter\Formatter
Method Summary¶
public
bool
accepts( string $acceptHeader )
public
string
contentType()
public
string
format( Payload $payload )
Methods¶
accepts()¶
contentType()¶
format()¶
ADR\Responder\JsonResponder¶
Class Source on GitHub
A formatted responder bound to the JSON formatter.
Phalcon\ADR\Responder\ChainResponderPhalcon\ADR\Responder\AbstractFormattedResponderPhalcon\ADR\Responder\JsonResponder
Uses Phalcon\ADR\Responder\Formatter\JsonFormatter
Method Summary¶
Methods¶
__construct()¶
ADR\Responder\Redirect¶
Class Source on GitHub
Value object describing a redirect. An Action sets it on the payload; the
RedirectResponder turns it into a Location header and status code.
Phalcon\ADR\Responder\Redirect
Method Summary¶
public
__construct(string $url,int $status = 302)
public
Redirect
permanent( string $url )
public
Redirect
seeOther( string $url )
public
int
status()
public
Redirect
temporary( string $url )
public
string
url()
Properties¶
protected
mixed
$status
protected
mixed
$url
Methods¶
__construct()¶
permanent()¶
seeOther()¶
status()¶
temporary()¶
url()¶
ADR\Responder\RedirectResponder¶
Class Source on GitHub
Applies a Redirect value object carried on the payload result: sets the
status code and the Location header. A no-op when the result is not a
redirect.
Phalcon\ADR\Responder\RedirectResponder- implementsPhalcon\Contracts\ADR\Responder\Responder
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface
Method Summary¶
Methods¶
__invoke()¶
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
Payload $payload
): ResponseInterface;
ADR\Responder\StatusMapper¶
Final Source on GitHub
Maps a domain Status to an HTTP status code.
Status is the single source of truth: the default map covers every
Status constant. Any status that is not mapped resolves to 500, never a
silent 200. Every entry can be overridden through the constructor.
Phalcon\ADR\Responder\StatusMapper
Uses Phalcon\ADR\Payload\Status
Method Summary¶
public
__construct( array $overrides = [] )
public
int
toHttpCode( string $status )
Returns the HTTP status code for the given domain status.
Properties¶
protected
array<int, int>
$map
Methods¶
__construct()¶
toHttpCode()¶
Returns the HTTP status code for the given domain status.
An unmapped status resolves to 500 (server error), never a silent 200.
ADR\Responder\StatusResponder¶
Class Source on GitHub
Sets the response HTTP status code from the payload status, via StatusMapper.
Phalcon\ADR\Responder\StatusResponder- implementsPhalcon\Contracts\ADR\Responder\Responder
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct( StatusMapper $mapper = null )
public
ResponseInterface
__invoke(RequestInterface $request,ResponseInterface $response,Payload $payload)
Properties¶
protected
mixed
$mapper
Methods¶
__construct()¶
__invoke()¶
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
Payload $payload
): ResponseInterface;
ADR\Responder\TextResponder¶
Class Source on GitHub
A formatted responder bound to the text formatter.
Phalcon\ADR\Responder\ChainResponderPhalcon\ADR\Responder\AbstractFormattedResponderPhalcon\ADR\Responder\TextResponder
Uses Phalcon\ADR\Responder\Formatter\TextFormatter
Method Summary¶
Methods¶
__construct()¶
ADR\Responder\ViewResponder¶
Final Source on GitHub
Renders a template from the payload and returns it as an HTML response.
The HTML sibling of JsonResponder: serialization is swapped for rendering,
the status mapping and the Responder contract stay the same. It depends on
the neutral Renderer contract only, so the ADR component never imports the
MVC view.
Phalcon\ADR\Responder\ViewResponder- implementsPhalcon\Contracts\ADR\Responder\Responder
Uses Phalcon\Contracts\ADR\Payload\Payload · Phalcon\Contracts\ADR\Responder\Responder · Phalcon\Contracts\View\Renderer · Phalcon\Http\RequestInterface · Phalcon\Http\ResponseInterface
Method Summary¶
public
__construct(Renderer $renderer,StatusMapper $statusMapper,string $template = "")
public
ResponseInterface
__invoke(RequestInterface $request,ResponseInterface $response,Payload $payload)
public
static
withTemplate( string $template )
Returns a copy of the responder bound to the given template. The action
protected
array
viewData( Payload $payload )
Flattens the payload into the variables handed to the template. The
Properties¶
protected
mixed
$renderer
protected
mixed
$statusMapper
protected
string
$template = ""
Methods¶
__construct()¶
public function __construct(
Renderer $renderer,
StatusMapper $statusMapper,
string $template = ""
);
__invoke()¶
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
Payload $payload
): ResponseInterface;
withTemplate()¶
Returns a copy of the responder bound to the given template. The action names the view; the payload stays free of presentation concerns.
viewData()¶
Flattens the payload into the variables handed to the template. The extras travel as they are, so an action can hand the view whatever the result should not carry.
ADR\Router\AttributeFilter¶
Final Source on GitHub
Reads an Action's optional static params() declaration and transforms the
router's positional tail segments: regex match (miss => RouteNotFound), cast
to a scalar type, then an optional converter closure. Declaration order names
the attributes; a declared parameter with no segment is skipped; surplus
segments pass through under their positional keys. An Action without
params() is returned unchanged.
Phalcon\ADR\Router\AttributeFilter- implementsPhalcon\Contracts\ADR\Router\AttributeFilter
Uses Phalcon\ADR\Exceptions\RouteNotFound · Phalcon\Contracts\ADR\Router\AttributeFilter
Method Summary¶
public
array
filter(string $actionClass,array $attributes)
protected
cast(string $value,string $type)
Methods¶
filter()¶
cast()¶
ADR\Router\Router¶
Final Source on GitHub
Convention router. method + static path -> Action class; the path tail
becomes positional request attributes. Middleware is resolved from a
namespace-prefix map (group semantics); global middleware stays on the
pipeline. No route table.
The convention¶
Every static path segment is a namespace segment, and the class name is the verb followed by all of those segments concatenated:
GET / -> Get
GET /profiles -> Profiles\GetProfiles
GET /company/all -> Company\All\GetCompanyAll
GET /company/all/7 -> Company\All\GetCompanyAll with ["7"]
POST /session/forgot-password -> Session\ForgotPassword\PostSessionForgotPassword
Guarantees¶
- One path names exactly one class; that class names exactly one path.
classFor()andpathFor()are pure functions of their input. Neither touches the filesystem, and neither consults any Action but the one it was given, so adding or deleting an Action can never move another one's URL.- There is no candidate list and no first-that-exists. Nothing can be shadowed.
Constraints - these are load-bearing, not style¶
- Arguments always trail the static path.
/album/edit/1, never/album/1/edit. A class name encodes which segments exist, not where a value sits among them; putting an argument in the middle would require consulting some other Action to find the boundary, and that is exactly the coupling this convention exists to avoid. params()never affects routing. It constrains, casts and converts attributes after a match. A wrong declaration is a validation bug, never a 404.- No route table, no compile step, no cache. Resolution is a string
derivation plus one
class_exists. In PHP's shared-nothing model a table must be rebuilt or reloaded on every request, and that cost dominates matching - which is why this router is faster in practice than a cached table-driven one. - Nothing may be layered onto the naming convention to express argument position, arity or ordering. Any such declaration is a path template in disguise, and a path template belongs in a declared-route router, not here.
The cost of all of this is /album/edit/1 rather than /album/1/edit. That
is a spelling difference, not a capability one - and it is not a deviation
from any standard. REST is Fielding's dissertation, not an RFC; RFC 3986 and
RFC 9110 both leave path structure entirely to the origin server.
Phalcon\ADR\Router\Router- implementsPhalcon\Contracts\ADR\Router\Router
Uses Phalcon\ADR\Exceptions\ActionDirectoryNotSet · Phalcon\ADR\Exceptions\MethodNotAllowed · Phalcon\Contracts\ADR\Router\Router · Phalcon\Contracts\ADR\Router\RouterMatch · Phalcon\Http\RequestInterface
Method Summary¶
public
array
candidatesFor(string $method,string $path)
Every Action class this router would try for the given method and path,
public
string
classFor(string $method,string $path)
The class this convention names for a fully static path, derived without
public
RouterMatchInterface|null
match( RequestInterface $request )
public
string|null
methodFor( string $className )
public
string|null
pathFor( string $className )
public
RouterInterface
setActionDirectory( string $actionDirectory )
public
RouterInterface
setBaseNamespace( string $baseNamespace )
public
RouterInterface
setMiddlewareMap( array $middlewareMap )
public
RouterInterface
setWordSeparator( string $wordSeparator )
protected
array
actionParams( string $className )
An Action's declared positional parameters, or an empty array when it
protected
string
camelize( string $segment )
protected
string
decamelize( string $part )
protected
array
deriveCandidates(string $method,string $path)
The single derivation of the routing convention.
protected
bool
hasSubNamespace( string $subNamespace )
protected
array|null
locate(string $method,string $path)
protected
array
middlewareFor( string $className )
protected
string|null
verbOf( string $className )
The class-name-form verb the given Action class carries, or null when the
protected
array
verbs()
The HTTP verbs the convention recognises, in class-name form.
Properties¶
protected
string
$actionDirectory = ""
protected
string
$baseNamespace = ""
protected
array<string, string[]>
$middlewareMap = []
protected
string
$wordSeparator = "-"
Methods¶
candidatesFor()¶
Every Action class this router would try for the given method and path, in the order it tries them. The first that exists wins at match time. Namespace descent consults the filesystem, so the list depends on the action directory.
classFor()¶
The class this convention names for a fully static path, derived without consulting the filesystem.
candidatesFor() cannot answer this. It walks the action directory to find where static segments end, so a path whose directories do not exist yet yields nothing - and a generator needs the name precisely in order to create them. Every static segment is a namespace segment, so the answer is unambiguous and pathFor() inverts it exactly.
Placeholders are the caller's concern: pass the static prefix only.
match()¶
methodFor()¶
pathFor()¶
setActionDirectory()¶
setBaseNamespace()¶
setMiddlewareMap()¶
setWordSeparator()¶
actionParams()¶
An Action's declared positional parameters, or an empty array when it declares none.
This is what lets an argument sit between two static segments: the
walk needs to know how many segments a level consumes before it can
carry on matching. params() is static and already exists for filtering
and casting, so nothing new is asked of an Action - but declaring it now
decides routing, not just validation.
camelize()¶
decamelize()¶
deriveCandidates()¶
The single derivation of the routing convention.
Every static path segment becomes a namespace segment, and the class name
is the verb followed by all of those segments concatenated - so
/company/all is Company\All\GetCompanyAll and nothing else. One path
yields exactly one class, and pathFor() inverts it exactly.
Segments are consumed while the matching directory exists; whatever remains is a dynamic argument. That walk decides where static ends and dynamic begins - it no longer chooses between competing class shapes, because there is only one.
hasSubNamespace()¶
locate()¶
middlewareFor()¶
verbOf()¶
The class-name-form verb the given Action class carries, or null when the class is not one this convention would have produced.
The class name is the verb followed by every namespace segment, so the namespace alone reconstructs the static path and the class name only has to agree with it. Anything that does not agree is not a class this convention would ever have produced.
Shared by pathFor() and methodFor() so that rule is stated once.
verbs()¶
The HTTP verbs the convention recognises, in class-name form.
ADR\Router\RouterMatch¶
Final Source on GitHub
Immutable result of a successful route match.
Phalcon\ADR\Router\RouterMatch- implementsPhalcon\Contracts\ADR\Router\RouterMatch
Uses Phalcon\Contracts\ADR\Router\RouterMatch
Method Summary¶
public
__construct(string $action,array $attributes = [],array $middleware = [],string $name = null)
public
string
getAction()
public
array
getAttributes()
public
array
getMiddleware()
public
string|null
getName()
Properties¶
protected
string
$action
protected
array
$attributes
protected
array
$middleware
protected
string|null
$name
Methods¶
__construct()¶
public function __construct(
string $action,
array $attributes = [],
array $middleware = [],
string $name = null
);