slim/php-view
slim/php-view is a lightweight view renderer for Slim Framework 4 that uses plain PHP templates with no compilation step or custom syntax. It supports layouts and partials through the PhpRenderer class, making server-side rendering simple and fast for developers who prefer native PHP over template e...
Architecture fit. slim/php-view is a PSR-7 response renderer, not a Laravel view engine. Its public surface is PhpRenderer::render(ResponseInterface $response, string $template, array $data): ResponseInterface, plus layout and shared-attribute setters. It slots into a Slim 3/4 middleware pipeline where a route handler has a PSR-7 response to decorate. Laravel's view layer instead expects an Illuminate\Contracts\View\Engine behind Illuminate\View\Factory/FileViewFinder, with Blade compilation and Laravel-native response handling. There is no service provider, facade, config publishing, or Laravel integration of any kind. Fit is therefore strong only when the host is a Slim application (or a PSR-7 middleware stack); it is weak as the primary view layer of a Laravel application. Release 3.4.0 does not change this: it is a dependency-constraint widening only, with no new API surface, no service provider, and no Laravel-facing features.
Integration feasibility. Technically possible, but it requires deliberate plumbing. A Laravel controller would need a PSR-7 request/response pair (via symfony/psr-http-message-bridge plus a PSR-7/PSR-17 implementation such as nyholm/psr7 or slim/psr7), a singleton PhpRenderer bound with a template path and response factory, and conversion of the returned PSR-7 response back to a Symfony/Laravel response. That is a bridge layered on a bridge. The cleaner pattern is to keep slim/php-view inside a bounded Slim module and either mount/delegate to it from Laravel or run it as a separate service during a migration window. Feasibility is high for the transitional case, low for greenfield Laravel.
3.4.0 materially lowers one specific friction point: psr/http-message ^2.0 is now accepted. Hosts built on Laravel 10+/Symfony 6+ stacks, nyholm/psr7 1.x, or slim/psr7 1.x are typically pinned to psr/http-message 2.x, so this package previously required a Composer conflict workaround, a version alias, or a downgrade of the PSR-7 implementation to coexist. That workaround is gone. Note the scope carefully: the 2.0 PSR-7 interfaces are covariant with the 1.x contract in the ways this renderer relies on (it consumes a ResponseInterface and returns one), so no code change is implied for consumers — but the package still does not declare a PSR-17 response factory dependency, so the host must supply one.
Technical risk.
htmlspecialchars() correctly; this is an ongoing code-review obligation, not a one-time configuration. Unaddressed by 3.4.0.included. If any part of the template name is user-influenced, validate against an allowlist—path traversal is a realistic concern.setAttributes()/addAttribute() live on the renderer instance. Under Octane/RoadRunner or any long-running worker, a singleton renderer can bleed data between requests. Unaddressed by 3.4.0; this is the item most likely to bite in a Laravel deployment.composer.json constraint widening (Allow version 2.0 of "psr/http-message"), no breaking changes and no runtime code path altered. The residual risk is transitive — accepting psr/http-message 2.x may shift what Composer resolves for neighbouring packages in a shared lockfile. Verify with a dry-run and a full test suite pass, not a constraint read.Key questions.
psr/http-message 2.x? If so, does 3.4.0 clear the last blocker, and does the resulting dependency set still conflict with existing framework constraints?Stack fit. Adopt only where a PSR-7 boundary already exists: a Slim 3/4 app inside a monorepo, a Slim route group being migrated into Laravel, or a service that already returns PSR-7 responses. For a pure Laravel application, Blade is the correct default and slim/php-view should not displace it. The package's real value is as a compatibility layer while Slim code is still in production.
Migration path. Inventory Slim routes and their templates first, then stand up PhpRenderer behind an internal adapter service so call sites depend on an interface rather than the package directly. From there, either delegate Laravel routes to the Slim app (request conversion plus response conversion) or run the Slim component as a separate service behind a reverse proxy during the transition. Migrate template-by-template to Blade, route-by-route, and delete slim/php-view once the last Slim route is retired. The package should be treated as interim scaffolding with a scheduled removal date, not a target-state dependency. Nothing in 3.4.0 argues for extending that removal date; it removes an install-time obstacle, not a reason to keep the package longer.
Compatibility. Verify the Composer constraints against the host PHP version and the Slim version in use—the package is tied to the Slim view contract in older lines, so a Slim major-version bump can force a package bump. With 3.4.0, pin ^3.4 rather than ^3.3 if the host is on psr/http-message 2.x; pinning an older 3.x line will silently reintroduce the constraint conflict. Confirm the chosen PSR-7 implementation and PSR-17 response factory are already present or acceptable — 3.4.0 widens the message-interface constraint but says nothing about the PSR-17 factory, which remains host-supplied. Isolate the dependency (separate composer package, path repository, or module boundary) so its transitive constraints cannot block framework upgrades; the 3.4.0 change reduces that risk but does not eliminate it for future PSR releases. Add a smoke test that renders every template to catch missing files and layout misconfiguration at build time rather than in production.
Sequencing.
psr/http-message major version.Gate the whole effort on step 3—if the escaping discipline cannot be enforced mechanically, do not proceed. The 3.4.0 compatibility win does not offset an uncontrolled escaping posture.
Maintenance. Low release cadence and a small maintainer pool mean the package is effectively frozen. 3.4.0 is a single narrowly scoped constraint change rather than evidence of a sustained roadmap; treat it as a data point, not a trend. It is tolerable for a stable, ~hundreds-of-lines renderer, but it must be pinned and monitored, with a named internal owner and a fork/vendor contingency documented. Budget a small annual review to confirm compatibility with PHP and PSR interface updates—the 3.4.0 release is precisely the kind of change that review is meant to catch, and it took roughly a year, so do not assume future PSR ecosystem shifts will be absorbed promptly.
Support. MIT-licensed, community-only, no commercial SLA. Any production incident is internally owned. The 3.4.0 contribution shows the issue/PR path is alive, which slightly improves the odds of a community fix landing, but it is not a support commitment. For a transitional dependency this is acceptable; for a long-lived core dependency it is not.
Scaling. Rendering is a plain include per request with output buffering. OPcache makes this cheap, and for typical web traffic the overhead is negligible. There is no template compilation, so there is no compiled-cache warmup or invalidation burden—but also no compile-time error detection. Avoid it in high-QPS paths where rendering dominates, and avoid re-instantiating the renderer per request unnecessarily.
Failure modes.
psr/http-message 3.0 or a Slim major bump would recreate the same scenario.psr/http-message 2.x across the tree and changes behaviour in adjacent PSR-7/PSR-17 consumers; run the full test suite after bumping, not just a render smoke test.Ramp-up. Low for PHP developers comfortable with plain templates; moderate for Blade-only teams, because the mental model shifts from auto-escaping and compiled directives to manual escaping and explicit layout wiring. Onboarding should include a short convention guide covering the escape helper, layout usage, template directory boundaries, and the rule that template names are never derived from user input. Expect a temporary productivity dip from running two templating stacks in parallel—another argument for keeping the adoption window short and the removal milestone explicit.
How can I help you explore Laravel packages today?