slimphp/Slim · error · RuntimeException

Middleware %s does not exist

Error message

Middleware %s does not exist

What it means

Error "Middleware %s does not exist" thrown in slimphp/Slim.

Source

Thrown at Slim/MiddlewareDispatcher.php:210

                    $resolved = $this->middleware;
                    $instance = null;
                    $method = null;

                    /** @psalm-suppress ArgumentTypeCoercion */
                    // Check for Slim callable as `class:method`
                    if (preg_match(CallableResolver::$callablePattern, $resolved, $matches)) {
                        $resolved = $matches[1];
                        $method = $matches[2];
                    }

                    if ($this->container && $this->container->has($resolved)) {
                        $instance = $this->container->get($resolved);
                        if ($instance instanceof MiddlewareInterface) {
                            return $instance->process($request, $this->next);
                        }
                    } elseif (!function_exists($resolved)) {
                        if (!class_exists($resolved)) {
                            throw new RuntimeException(sprintf('Middleware %s does not exist', $resolved));
                        }
                        $instance = new $resolved($this->container);
                    }

                    if ($instance && $instance instanceof MiddlewareInterface) {
                        return $instance->process($request, $this->next);
                    }

                    $callable = $instance ?? $resolved;
                    if ($instance && $method) {
                        $callable = [$instance, $method];
                    }

                    if ($this->container && $callable instanceof Closure) {
                        $callable = $callable->bindTo($this->container);
                    }
                }

View on GitHub (pinned to 80900fb39c)

When it happens

Trigger: Thrown at Slim/MiddlewareDispatcher.php:210 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slimphp/Slim@80900fb39c (2026-08-21). Data as JSON: /api/errors/9033d538d77969fc. Report an issue: GitHub.