Renato Hysa

Renato Hysa

@hysa.dev

Building @gaplos.com | Crafting the next-gen Laravel boilerplate using DDD (95%+ coverage) | Turning curiosity into code | Open for work πŸš€

48 followers91 following232 posts

πŸ›οΈ DDD in Laravel = everything has a home. What you get: βœ… Business logic in Domain layer βœ… Orchestration in Use Cases βœ… Framework code isolated βœ… New devs onboard faster $order->cancel() > $order->status = 'cancelled' Structure brings clarity 🎯 #PHP

πŸ”₯ Unpopular: Model factories are overused. Most tests need: ❌ User::factory()->create() βœ… User::create(['email' => 'test@test.com']) Save factories for: * Database seeding * Complex relationships * Random data generation Be explicit. Be clear πŸ“ #Laravel

πŸ”₯ Controversial: Static methods are fine, actually. Good static use: βœ… Math::round() βœ… Str::slug() βœ… Carbon::parse() βœ… Validator::make() Bad static use: ❌ DB::query() ❌ Cache::get() Context matters. Stop the dogma 🎯 #PHP

⚠️ Singleton = anti-pattern alert. Problems: ❌ Cannot mock for tests ❌ Global state ❌ Hidden dependencies ❌ Hard to maintainUse Dependency Injection instead βœ… #PHP

🏭 Simple Factory = clean object creation. Perfect for: βœ… Dynamic object instantiation βœ… Mockable for testing βœ… Type-based creation βœ… Centralized logic One factory, many objects πŸš€ #PHP

πŸ”„ Prototype = clone instead of create. Perfect for: βœ… Mass data operations βœ… Expensive object creation βœ… Bulk record generation βœ… Pre-configured templatesClone it, don't build it πŸš€ #PHP

♻️ Object Pool = stop wasting time creating objects. Perfect for: βœ… Database connections βœ… HTTP clients βœ… Expensive resources βœ… High-frequency operations Reuse, don't recreate πŸš€ #PHP

🏭 Factory Method = dependency inversion done right. Perfect for: βœ… Multiple logger destinations βœ… Testable with mock factories βœ… Database/file/cloud storage βœ… Zero client code changes SOLID principles in action πŸ’ͺ #PHP

πŸ”¨ Builder Pattern = no more constructor chaos.Perfect for: βœ… Complex object assembly βœ… Multiple object variations βœ… Step-by-step construction βœ… Avoiding parameter overloadClean, flexible, maintainable πŸ’ͺ #PHP

🏭 Abstract Factory = object creation made elegant. Perfect for: βœ… Multi-platform apps (Windows/Unix/Mac) βœ… Swappable export formats (CSV/JSON/XML) βœ… Theme systems (Dark/Light) βœ… Test mocking without refactoring One interface, unlimited implementations πŸš€ #PHP

Nested if-statements killing you? Perfect for: βœ… Less cognitive load βœ… Obvious happy path βœ… Fail fast, win clear βœ… Reads like a checklist Guard clauses > pyramids of doom πŸ›‘οΈ #laravel

Still writing PHP like it's 2015? Perfect for: βœ… Less constructor boilerplate βœ… Clean match expressions βœ… Arrow function callbacks βœ… Self-documenting calls Modern PHP is clean πŸš€ #laravel

Breaking chains for side effects? Perfect for: βœ… Keep fluent chains flowing βœ… Debug mid-chain easily βœ… Side effects, no breaks βœ… Natural top-to-bottom code The chain never breaks πŸ”— #laravel

Processing huge datasets wrong? Perfect for: βœ… Handle millions of records βœ… Right tool for the job βœ… Safe updates while iterating βœ… Chain methods on big data Memory matters 🧠 #laravel

Laravel devs Why would someone prefer Laravel Nova over Filament PHP? Especially when you consider that Laravel Nova is a paid option. πŸ€” #laravel

Searching multiple columns with orWhere? Perfect for: βœ… Apply constraint to many columns βœ… No repetitive chains βœ… Clean content filtering βœ… Matches your intent One method beats ten 🎯 #laravel

Query builder if-statements everywhere? Perfect for: βœ… Conditional clauses, no chain breaks βœ… Clean search filter handling βœ… No nested if-blocks βœ… Default behavior with else Keep the chain flowing 🌊 #laravel

Collection closures too verbose? Perfect for: βœ… Call methods without closures βœ… Cleaner transformation chains βœ… Less boilerplate code βœ… Readable nested access One line beats five πŸ“ #laravel

Queue jobs killing your API limits? Perfect for: βœ… Respect API rate limits βœ… Prevent service overload βœ… Per-user throttling βœ… No more 429 errors Background work, under control πŸŽ›οΈ #laravel

Manual JSON encode/decode everywhere? Perfect for: βœ… Rich value objects βœ… Auto encrypt/decrypt βœ… No manual transformation βœ… Encapsulated domain logic Work with objects, store as JSON πŸ”„ #laravel

Model event logic scattered everywhere? Perfect for: βœ… Centralized event handling βœ… Clean, focused models βœ… Auto-sync across systems βœ… Isolated testing One observer beats 50 callbacks 🎯 #laravel

Moved all our user event handling to an observer and deleted 300 lines from the User model, code reviews take half the time now.

Your API needs rate limiting Perfect for: βœ… Protecting against abuse βœ… Tiered access (free vs paid) βœ… Custom limit segmentation βœ… Fair resource allocation Stop bleeding infrastructure costs πŸ’Έ #laravel

🧠 Stop querying the same data twice! Perfect for: βœ… Multi-pass processing βœ… Dashboard aggregations βœ… Complex reports βœ… Data transformations Laravel's remember() caches lazy collection results πŸ’Ύ #laravel

Anyone else been embarrassed by seeing 47 identical queries in Laravel Debugbar because you forgot to cache your collection? πŸ˜… The remember() method is your new best friend!Retry

πŸ”’ Timing attacks revealing your secrets? Perfect for: βœ… Authentication checks βœ… Password comparisons βœ… Cryptographic operations βœ… API key validations Laravel's Timebox ensures constant execution time πŸ›‘οΈ #laravel

πŸ—‘οΈ Laravel Soft Deletes = Never lose data Perfect for: βœ… Data recovery βœ… Audit trails βœ… Trash features βœ… Compliance needs Records stay in the database, just hidden πŸ”’ #laravel

πŸ”’ Laravel Atomic Locks = Zero race conditions Perfect for: βœ… Duplicate prevention βœ… Critical operations βœ… Distributed coordination No external services needed πŸš€ #laravel

Prevent the same Laravel job from running twice simultaneously. Automatic queue release if job is already processing. Perfect for credit updates, reports, any operation that can't overlap. One line. Zero race conditions. #laravel

Laravel Pennant = Feature flags without the complexity Roll out features gradually: βœ… 1% of users first βœ… Kill switch if issues βœ… A/B test variations βœ… Team-based access One Feature::define() call, check anywhere. Database-backed. Built-in caching. No SaaS fees. Pure Laravel. πŸ”₯ #laravel

🀯 Laravel Model Broadcasting = Real-time updates with ZERO boilerplate Add BroadcastsEvents trait to your model & Laravel auto-broadcasts: βœ… Created βœ… Updated βœ… Deleted βœ… Restored No custom events needed. Frontend gets instant updates automatically. This is why I love Laravel πŸ”₯ #laravel

πŸ”₯ Laravel's HTTP Client fires 3 events you should know about: 🎯 RequestSending - before the request πŸ“¨ ResponseReceived - after response ❌ ConnectionFailed - when it fails Perfect for: βœ… Logging all API calls βœ… Monitoring performance βœ… Error tracking Game-changer for API-heavy apps! πŸš€ #laravel

🧠 Your brain isn't built for memorization, it's built for recognizing patterns. Top devs don't memorize every function. They build systems for debugging, code review, and knowledge sharing. Solid systems = everything clicks Broken systems = spinning wheels #laravel #php #remote

Who would have thought that I would get more views than StackOverflow in 21min. P.S. there are still questions being downvoted out of nothing πŸ˜‚StackOverflow is a really dark place 😎

Freelancing is dying... 5 minutes on Upwork and you will see countless examples like the one in the screenshot. Non-technical people create a prototype using AI and tools such as Lovable and call it production ready πŸ˜‚ What you see in the screenshot, is 1/3 of the requirements