anomaly/request-plugin
Anomaly Request Plugin adds request handling utilities to Anomaly CMS, helping Laravel developers manage incoming HTTP requests, validate input, and streamline request workflows in their applications.
anomaly/request-plugin is a Twig plugin for the Anomaly Labs Streams Platform (the engine behind PyroCMS 3.x). It exposes the current HTTP request to templates so page/partial authors can read query strings, headers, and route data without writing a controller. Treat it as a template-layer helper, not an application-layer HTTP abstraction.
Minimal steps:
composer require anomaly/request-plugin:^1.0.src/ before anything else. The package is undocumented. The three files that matter are the service provider (addon registration), the plugin class (usually RequestPlugin), and the functions class that declares the Twig functions()/filters(). That functions class is the API surface — the method names are your template vocabulary.composer.json (extra.streams or extra.laravel.providers). Confirm php artisan addon:list (or the CP Addons screen) shows it as enabled before blaming the templates.{{ request.get('utm_campaign') }} in a page layout, with a default when absent. This is the lowest-risk introduction because it touches one template and is trivially removable.If the package is not already in your composer.lock, seriously consider a five-line custom Twig extension instead; you will get the same feature with maintained dependencies.
Template-only reads. The intended pattern is read-only, side-effect-free access from Twig partials and page layouts:
{% set ref = request.get('ref') ?: 'direct' %}
<p>Referred by {{ ref|e }}</p>
Keep all request access in one reusable partial (partials/request-banner.twig) rather than sprinkling calls through page bodies. When you eventually migrate off the addon, you swap one file instead of grepping every template.
Branching on request shape. Because the plugin gives templates visibility into method/path/headers, page authors can render different blocks per entry point — e.g. showing a compact hero on ?embed=1. Prefer this only for presentation toggles. For anything behavioural (auth, redirects, pricing), do it in the controller and pass a boolean into the view; templates should not own logic.
Pairing with the Pages module. The natural integration is a custom page type whose view partial reads the plugin, so the page stays editable in the CP while still varying by query string. This is the one pattern where the plugin genuinely saves work versus passing data through a controller.
PHP-side coexistence. Do not replace Laravel's request() with the plugin in controllers or middleware — the plugin is Twig-scoped and adds no value there. The clean split is: controllers use request() and validate; templates use the plugin only for cosmetic/optional values. Mirror that in tests: a feature test that hits the route with ?utm_campaign=spring and asserts the rendered string is the right contract, and it shields you from the addon's internals.
Defensive defaults. Wrap every lookup so a missing key does not blank the page:
{{ request.get('promo', 'none')|e }}
Adopt this as a house rule in code review; it turns the plugin from a footgun into a stable helper.
|raw next to a plugin call is an XSS hole. Never feed plugin output into href, src, or inline <script>.{{ request.get('x') }} renders blank, check addon enablement and provider registration before touching the template.{{ dump(request) }} to see exactly what the plugin exposes; otherwise log from a throwaway route. Do not add var_dump inside the plugin class — Streams' addon bootstrapping will produce unreadable output mid-render.|e (or |escape) as the last filter in a chain, after defaults and string manipulation, or you will double-escape and see &amp; in the wild.Twig::extend. The latter is ~20 lines, has no abandoned dependency, and is what I would do if the plugin were not already in production.1.0.x, not ^1.0) and commit the lockfile. With no upstream activity, floating constraints buy you nothing and risk a future tag you have not tested.How can I help you explore Laravel packages today?