- What is lewis/presenter and what problem does it solve in Laravel?
- lewis/presenter is a small Laravel package for wrapping Eloquent models in dedicated presenter classes so view formatting and display logic stay out of Blade templates, controllers, and models. It gives you a simple, testable layer that turns model data into clean, view-ready values. It is presentation-only and does not replace API Resources, DTOs, or front-end components.
- Which Laravel and PHP versions does lewis/presenter support?
- The package is low-adoption and may target older Laravel and PHP conventions, so its supported version matrix should be verified before use. Check the composer.json constraints and run an install spike against your target Laravel and PHP versions in CI. Because it has zero dependents and limited maintenance signals, do not assume compatibility with current Laravel releases without testing.
- How do I install lewis/presenter with Composer?
- Install it with composer require lewis/presenter and confirm the resolved version matches your Laravel and PHP constraints. If package auto-discovery is not supported, register the service provider manually in your application configuration. Run a branch-level install first and commit a lockfile so upgrades remain deliberate.
- Does lewis/presenter support Laravel package auto-discovery?
- Auto-discovery may not be available given the package age and low adoption, so plan to verify it or register the service provider manually. Check the package composer.json for a Laravel extra block or provider entry. If discovery is missing, adding the provider to your application config is a small, contained change.
- How do I wrap an Eloquent model or collection in a presenter?
- Define a presenter class for the model display concerns, then wrap the model or collection where you prepare view data. Keep presenters read-only from the model perspective and expose simple display methods to Blade. Validate collection and pagination handling in your spike, since older packages may not cover those paths completely.
- Is lewis/presenter maintained and safe to use in production?
- Maintenance risk is elevated because the package has low adoption, zero dependents, and may carry stale Laravel assumptions, so community fixes are unlikely. Runtime risk is limited because the library is simple and presentation-only, but upgrade and ownership risk remain. Pin the dependency, monitor Laravel and PHP upgrades, and keep an in-house replacement path ready.
- Does lewis/presenter escape output by default to prevent XSS?
- Escaping behavior is not guaranteed by a thin presenter layer, so treat unescaped output as a failure mode to test. Use Blade escaped output in templates and only allow raw HTML through deliberate, reviewed helpers. Add tests that assert presentation output is escaped before shipping user-facing views.
- Can I use lewis/presenter with pagination and collections?
- Presenters can wrap collections, but pagination support is not guaranteed and should be validated in a representative spike. Confirm that paginator instances and collection transforms preserve links and metadata your views need. If support is incomplete, wrap pagination in your own adapter rather than patching the package broadly.
- Is lewis/presenter a good alternative to Laravel API Resources or Blade components?
- It fits Blade-rendered Laravel monoliths where display formatting should be kept out of templates and controllers, but it is less compelling for API-first services or Inertia and Livewire-heavy front ends. Laravel API Resources are stronger for API transformation, and Blade components are often better for markup-heavy presentation. Use this package only where a thin presenter layer is the clear fit.
- How should I test presenters and what extension points does lewis/presenter offer?
- Presenters should be plain, testable classes, so write unit tests that assert display methods return the expected escaped values without booting a full view. If documented extension points are thin, favor small presenter classes and an internal contract you own. Keep conventions for naming, return types, escaping, and test coverage documented for your team.