Expressive is a Laravel package that provides typed objects as a boundary between Eloquent models and business logic. Instead of passing Eloquent models everywhere, you convert them to fully typed PHP objects with explicit properties, enums, and nullability. Business actions then depend on these typed objects rather than the full database model, preventing accidental DB calls, improving static analysis, and making code easier to reason about. The package includes a generator and sync command to keep Expressive classes aligned with model changes. The author recommends using it selectively for complex business flows rather than replacing all Eloquent usage.

11m read timeFrom wendelladriel.com
Post cover image
Table of contents
IntroductionThe Problem With Passing Models EverywhereWhat Expressive Gives YouConverting Models Into Expressive ObjectsMoving Business Logic Away From the ModelThe Safety of Fully Typed ObjectsRelationships Without Lazy SurprisesGenerating and Keeping Objects in SyncA Few Practical RulesConclusion
64.4K Impressions2 Comments