- How do I install guilhermegonzaga/presenter in a Laravel app?
- Install it with Composer using composer require guilhermegonzaga/presenter. Then create presenter classes that extend the package base presenter and wire models using the trait or helper described in the package docs. This is a presentation-layer dependency, so start with one read model or view screen rather than every model. Confirm the service provider and trait behavior in your Laravel version before rollout.
- Which Laravel and PHP versions does this presenter package support?
- The provided overview does not list exact Laravel and PHP constraints, so check the package composer.json and repository tags before adopting it. Pin a specific version in composer.json and run your application CI matrix against the PHP and Laravel versions you actually support. Because adoption is low, verify compatibility rather than assuming current Laravel support.
- Does the package support Laravel package auto-discovery?
- Package auto-discovery depends on the package declaring a Laravel service provider in composer.json under extra.laravel.providers. The evaluation notes optional discovery, so confirm that entry in the installed version. If discovery is not present or fails, register the provider manually in config/app.php or the bootstrap providers file for your Laravel version.
- How do I create a presenter for an Eloquent model?
- Create a presenter class that extends the package base presenter and wrap the Eloquent model or other object you want to present. Add public methods for formatting, computed values, and view-ready output, keeping database access out of the presenter where possible. Then expose the presenter through the model trait or helper documented by the package. Add a feature test that renders the Blade view or JSON output to confirm the wrapper behaves as expected.
- Does the package resolve presenters through the Laravel service container?
- The package is a Laravel integration and presenters may be resolved through the container, but the overview does not guarantee it. The technical review flags container-resolution errors as a failure mode, so test any presenter that needs dependencies. If automatic resolution fails, instantiate the presenter manually or bind it in a service provider behind your own contract.
- How should I handle collections, pagination, and nested presenters?
- The overview does not specify collection or pagination helpers, so treat those as integration details to verify in the source and tests. A common approach is to map presenters over collection items and preserve paginator metadata with through or a transform callback. For nested presenters, compose presenter methods carefully and guard against recursive wrapping. Test query counts and output shape for list screens before broad use.
- Does wrapping a model in a presenter mutate it or change serialization?
- A presenter should decorate and wrap the underlying model, not mutate its attributes. Be careful if the presenter forwards property access or array conversion, because that can change what Blade or JSON responses see. Keep model serialization and presenter output separate, and add tests asserting the original model attributes remain unchanged. If you need API transformation, prefer Laravel API Resources over presenter-controlled toArray behavior.
- How do I test presenter output in Laravel?
- Write unit tests for presenter methods using simple model instances or factories, and feature tests for the Blade views or responses that consume them. Assert formatted values, computed fields, and that the underlying model is not mutated. Include query-count assertions when presenters touch relationships, because hidden N+1 queries are a scaling risk. Run these tests in your CI matrix against the pinned package and Laravel versions.
- Is this package suitable for API-only Laravel applications or should I use API resources?
- It is less compelling for API-only or headless services unless you use presenters strictly as response formatters. Laravel API Resources are usually a better fit for JSON contracts, while this package is strongest for conventional Laravel plus Blade view formatting. Keep presentation concerns out of domain logic and avoid making presenters a platform dependency.
- Is guilhermegonzaga/presenter maintained enough for production, and what are the alternatives?
- At roughly 46 stars, the package has limited community validation and likely single-maintainer risk, so treat it as an optional convenience layer. Pin the version, assign an internal owner, monitor releases and Laravel compatibility, and keep a fork or replacement path open. Verify the reported 2026-05-12 release for provenance, changelog quality, and test coverage before production use. Alternatives include Laravel API Resources, Blade components or view models, and custom decorator classes.