presenter

Easy view presenters for Laravel that keep display logic out of models and views.

Library
Composer
v0.2.8
865stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity0
Maintenance20
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture76
Code Quality76
Innovation68
Learning Curve90

Laracasts Presenter is a small PHP package that implements the view-presenter pattern for Laravel and Eloquent applications. When a bit of formatting logic needs to run before entity data is shown in a view, a presenter gives it a home - not hard-coded in the template, and not bloating the model.

You write a presenter class that extends the package’s base Presenter, add a trait to your model, and then call present() in your views to access formatted, display-ready attributes and methods. The result is cleaner models, tidier views, and one obvious place to change presentation logic.

What You Get

  • A base Presenter class to extend for display formatting methods
  • A PresentableTrait that auto-instantiates and caches the presenter
  • A present() accessor for reaching formatted attributes in views
  • Transparent access to the underlying entity’s raw attributes
  • A clear, single home for presentation logic separate from models and views

Common Use Cases

  • Formatting a user’s full name or display name for a view
  • Rendering human-friendly dates and statuses from model data
  • Keeping presentation logic out of Eloquent models
  • Centralizing view formatting so it is easy to find and change

Under The Hood

Architecture - The core is a small Laracasts\Presenter\Presenter base class (src/Laracasts) that wraps an entity and exposes its attributes via magic accessors, plus a PresentableTrait that lazily instantiates and caches the configured presenter behind a present() method. Tech Stack - Plain PHP with a Composer autoloader, designed to drop into Laravel/Eloquent but with no hard framework coupling beyond the trait convention; a small PHPUnit test suite accompanies it. Code Quality - The library is intentionally tiny and single-purpose, which keeps it easy to read and audit, though the project sees infrequent maintenance given its stable, complete scope. API Design - The pattern is almost invisible: extend Presenter, add a trait, set one property, and call present(), so the learning curve is minimal and the intent reads clearly at every call site.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search