Esc
API Index — Namespaces, Packages, Reports, Indices
BlockPhpExtMiddleware
in package
implements
MiddlewareInterface
Block .php Extension Middleware
Refuses any request whose path matches \.php(\?|$) with a 404. Useful for
apps that want extensionless URLs as the only public surface and don't want
/index.php, /admin.php, etc. to be reachable even when a public file
exists.
Apache equivalent — the classic .htaccess pattern:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ - [R=404,L]
nginx equivalent:
location ~ \.php$ { return 404; }
Usage in app.php:
$app->addMiddleware(new \ZealPHP\Middleware\BlockPhpExtMiddleware());
Table of Contents
Interfaces
- MiddlewareInterface
Methods
- process() : ResponseInterface
Methods
process()
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface