Refactoring to SOLID in Laravel
summary
Refactors a monolithic Livewire mortgage component into separate Blade pieces and plain PHP services, moving calculations and quoting out of the UI and into tested units. Extracts a calculate LTV service, a get product quotes service and a create product quote DTO, replaces DB-heavy tests with unit tests, uses Livewire events between form and search, and resolves flaky cases around LTV values like 75 80 and 79. Code is available on GitHub filmed at Laracon EU Amsterdam April 26 2022.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 3:21Laravel app example
- 7:57Monolithic component problems
- 10:25Extracting feature products
- 11:48Separating form and search
- 13:15Calculation service class
- 15:43DTOs for grouped data
- 16:25Product query service
- 18:12Product quote service
- 20:17Object composition principle
- 21:45Collections of DTOs
- 22:48Dependency inversion
- 23:53Guard clauses refactor
- 24:35Live Wire component final
- 25:38SOLID guidance
- 26:47Q&A
related talks
50mLiveWire Hands-on
50mVue.js x Laravel
40mEngineering Complex Applications with Laravel 4
27mPhilo Hermans :: Reusing Reusable Livewire Components
24mHelp out frustrated Bob
48mMigrating a 15 Year Old Enterprise Application to Laravel: Lessons Learned and Opportunities Gained
57mRefactoring a large legacy PHP Application: a case study
36mLiving peacefully with Laravel
