Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Middleware: request rules, input and output listeners

What takes the place of middleware, before and after filters and request listeners in Exponential - request rules that allow, deny, redirect, rewrite or log after URL translation and policies, the request/input and…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/help/web-framework-developers/middleware-and-request-rules.md

On this page

Middleware: request rules, input and output listeners

This page is for developers who put cross-cutting request logic into middleware (Laravel, Slim, Laminas, Express, Django), before and after filters (Rails, CodeIgniter) or kernel listeners (Symfony). Exponential has no generic middleware stack you add classes to. It has three places that together cover most middleware uses.

Contents

  1. The three places
  2. Request rules
  3. Input and output listeners
  4. Common middleware, translated
  5. What has no equivalent

The three places

PlaceRunsCanConfigured in
request/preinput, request/input listenersbefore URL translation and routinginspect the request, refuse it (as the CSRF check does), set up statesite.ini [Event] Listeners[]
Request rulesafter URL alias translation and after the policies allowed the viewallow, not found, forbidden, login, redirect, redirect to alias, rewrite, logsettings/requestrules.ini
response/preoutput, response/output filtersafter the pagelayout renderedchange the final output (as the form token insertion does)site.ini [Event] Listeners[]

The order inside a request is on The request lifecycle.

Request rules

Rules are settings: conditions and an action, asked in order, the first whose conditions all match decides (Request rules, complete guide with sixteen recipes: View full security).

# settings/siteaccess/<site>/requestrules.ini.append.php
<?php /*
[RequestRuleSettings]
RuleList[]=members_area

[Rule-members_area]
Description=Below node 864, anonymous visitors sign in first and come back.
Conditions[subtree]=864
Conditions[user]=anonymous
Action=login
*/ ?>
  • 25 conditions, among them requested_via (system, alias, wildcard, front page), uri, module_view, view_mode, node, subtree, class, section, state, user, role, policy, siteaccess, host, header, ip and fact.
  • 8 actions: allow, notfound, forbidden, login, redirect, redirect_to_alias, rewrite, log.
  • Rules only take access away or send the visitor elsewhere; they never give access a policy refused.
  • Any answer except allow is sent private, no-store.
  • Check what the rules decide without changing anything: php bin/php/ezrequestrules.php -s site --uri=content/view/full/2.

In PHP you can add conditions, actions, facts (ezpRequestFactProvider) and whole rule sets computed at run time (ezpRequestRuleProvider), registered in [RequestRuleSettings] (Extending the rules in PHP).

Input and output listeners

ezformtoken is the model of a middleware pair in Exponential. Its settings/site.ini.append.php registers:

[Event]
Listeners[]=request/input@ezxFormToken::input
Listeners[]=response/output@ezxFormToken::output

ezxFormToken::input() checks the token of every POST before routing; ezxFormToken::output() adds the hidden token field to every method="post" form in the final HTML. A filter listener such as response/output must return the value it receives, changed or not (Events and listeners).

Common middleware, translated

MiddlewareIn Exponential
Authentication required for an areasiteaccess RequireUserLogin; a request rule with Action=login; view functions
Authorizationpolicies on the view (functions), object checks in the view (Authorization)
CSRFezformtoken (Forms and CSRF)
IP allow list for an areaa request rule with Conditions[ip]
Redirect old addressesURL wildcards or a request rule with redirect (Pretty URLs)
Maintenance modeexpMaintenance in index.php (php bin/php/maintenance.php on) (Maintenance mode)
Security headers, Content Security Policysite.ini [ContentSecurityPolicy] and the security headers (Content Security Policy)
Response cachingthe view cache, the role-aware HTTP cache, the Velocity response cache (Caching)
Request loggingrequest logs and the audit trail (Request logs, Audit trail)
Trusted proxiessite.ini [HTTPHeaderSettings] TrustedProxies[] (Trusted proxies)

What has no equivalent

  • Per-route middleware lists (->middleware('auth') on one route): use view functions and request rules with a module_view condition.
  • Wrapping the whole call in a closure ($next($request)): listeners run before or after, not around. The runnable events (runnable/view/before and after) come closest for a single view.
  • Middleware ordering by priority: listeners run in the order of Listeners[]; rules in the order of RuleList[].

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x