Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php View Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.

  • Escaping/XSS: plain PHP templates provide no auto-escaping. Every output site must call htmlspecialchars() correctly; this is an ongoing code-review obligation, not a one-time configuration. Unaddressed by 3.4.0.
  • Template resolution: templates are resolved from a configured base path and included. If any part of the template name is user-influenced, validate against an allowlist—path traversal is a realistic concern.
  • State leakage: shared attributes set via 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.
  • No compilation step: there is no compiled-template cache, which means no cache invalidation problems but also no compile-time validation; missing templates and syntax issues surface only at request time.
  • Upgrade risk (3.4.0): low. The change is a 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.
  • Ecosystem signal: 273 stars, 0 reported dependents, and an opportunity score of 35.42 still point to a small, low-velocity package. The 3.4.0 release slightly improves the velocity read — a maintainer merged an external contribution (PR #109, credited to @Kekos) — which is modest positive evidence of responsiveness and of a functioning contribution path. It does not change the fundamental conclusion: the codebase is small enough to fork if necessary, but that remains a contingency, not a strategy.

Key questions.

  1. Is Laravel the actual host, or is this for an embedded/legacy Slim 3/4 component?
  2. Which PSR-7 and PSR-17 implementations will be standardized, and are they now on 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?
  3. What is the escaping policy, and who enforces it in review and static analysis?
  4. Does the deployment run under Octane or another long-lived worker where renderer state would persist?
  5. Is there an existing Blade/Twig investment, and what would a second templating stack cost in cognitive load?
  6. What is the exit plan if the package goes unmaintained—fork, vendor, or accelerate migration?

Integration Approach

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.

  1. Timeboxed spike: render one representative template through the adapter in a branch, on the target psr/http-message major version.
  2. Add the PSR-7 bridge and response conversion; document the request/response lifecycle.
  3. Security review of escaping and template-name handling; add linting or a strict coding standard.
  4. Parity tests comparing rendered output against the existing Slim behavior.
  5. Composer dry-run on 3.4.0 against the real lockfile; confirm no transitive downgrades of PSR packages.
  6. Route-by-route cutover, then decommission the package and its bridge dependencies.

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.

Operational Impact

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.

  • Missing or misnamed template → runtime exception; ensure a global handler maps this to a 500 rather than partial output.
  • Layout not set or set to an invalid path → blank or malformed page; add a render smoke test per template.
  • Unescaped output → XSS; the highest-severity and most likely failure, and untouched by 3.4.0.
  • Shared-attribute bleed under Octane/long-running workers → cross-request data exposure; use scoped bindings or reset attributes per request.
  • Exceptions thrown mid-render with active output buffering → leaked buffers or truncated bodies; verify buffer cleanup in the adapter.
  • Composer constraint conflict on Slim/PSR versions → blocked framework upgrades; isolate the dependency. Lowered but not eliminated by 3.4.0—a future psr/http-message 3.0 or a Slim major bump would recreate the same scenario.
  • Post-upgrade resolution drift → a lockfile update that pulls 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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core