Skip to content

MiddlewareOrderException

Thrown by MiddlewareOrderResolver when a #[Middleware] ordering constraint cannot be honoured and there is no safe fallback: either the before/after constraints form a cycle, or a guarded (framework) middleware’s constraint names something that isn’t there.

An unresolvable reference on app or plugin middleware still degrades to a Diagnostic and is skipped — anchoring to an optional package’s middleware is a legitimate pattern, and that middleware simply falls back to its phase and priority. For framework middleware it is not survivable: those constraints are how a security check’s position in the pipeline is guaranteed at all, so silently dropping one turns “CSRF runs before dispatch” into “CSRF happens to * run before dispatch, given the current priorities”.

final class MiddlewareOrderException extends RuntimeException

ExtendsRuntimeException
Since1.0.0
SourceMiddleware/Compiler/MiddlewareOrderException.php
MethodDescription
cycle(array<string> $involved): MiddlewareOrderException
unresolvedGuardedReference(string $from, string $reference, string $why): MiddlewareOrderException

public static function cycle(array<string> $involved): MiddlewareOrderException

FQCNs of the middleware still unordered when the cycle was detected.

ParameterTypeDescription
$involvedarray``<``string``>FQCNs of the middleware still unordered when the cycle was detected.

Returns MiddlewareOrderException

public static function unresolvedGuardedReference(string $from, string $reference, string $why): MiddlewareOrderException

What was wrong with it (unknown, or ambiguous).

ParameterTypeDescription
$fromstringThe guarded middleware carrying the constraint.
$referencestringThe unresolvable before/after target as written.
$whystringWhat was wrong with it (unknown, or ambiguous).

Returns MiddlewareOrderException

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
getCode()Exception
getFile()Exception
getLine()Exception
getMessage()Exception
getPrevious()Exception
getTrace()Exception
getTraceAsString()Exception