Advertisement Β· 728 Γ— 90

Posts by Renato Hysa

πŸ›οΈ 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

4 months ago 1 0 0 0

πŸ”₯ 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

4 months ago 0 0 0 0

πŸ”₯ 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

4 months ago 0 0 0 0
Post image Post image Post image Post image

⚠️ Singleton = anti-pattern alert.

Problems:

❌ Cannot mock for tests
❌ Global state
❌ Hidden dependencies
❌ Hard to maintainUse Dependency Injection instead βœ…

#PHP

5 months ago 1 0 0 0
Post image Post image Post image

🏭 Simple Factory = clean object creation.

Perfect for:
βœ… Dynamic object instantiation
βœ… Mockable for testing
βœ… Type-based creation
βœ… Centralized logic

One factory, many objects πŸš€

#PHP

5 months ago 1 0 0 0
Post image Post image Post image

πŸ”„ 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

5 months ago 1 0 0 0
Post image Post image Post image

♻️ Object Pool = stop wasting time creating objects.

Perfect for:
βœ… Database connections
βœ… HTTP clients
βœ… Expensive resources
βœ… High-frequency operations

Reuse, don't recreate πŸš€

#PHP

5 months ago 0 0 0 0
Post image Post image Post image Post image

🏭 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

5 months ago 1 0 0 0
Advertisement
Post image Post image Post image Post image

πŸ”¨ Builder Pattern = no more constructor chaos.Perfect for:

βœ… Complex object assembly
βœ… Multiple object variations
βœ… Step-by-step construction
βœ… Avoiding parameter overloadClean, flexible, maintainable πŸ’ͺ

#PHP

5 months ago 1 0 0 0

I have used that in the next post, good catch ;)

5 months ago 0 0 0 0
Post image Post image Post image

🏭 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

5 months ago 1 0 0 0
Post image Post image

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

5 months ago 3 1 1 0
Post image Post image Post image Post image

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

5 months ago 1 0 0 0
Post image Post image

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

5 months ago 0 0 0 0
Post image Post image Post image

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

5 months ago 0 0 0 0
Post image

Windows users don't know what this screenshot is πŸ˜‚

#ai

5 months ago 0 0 0 0

Interesting, what issues have you had and reached to support? Filament is open source, thus the community is the only support you can get πŸ˜…

5 months ago 0 0 1 0

Laravel devs

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

#laravel

5 months ago 2 0 1 0
Advertisement
Post image Post image Post image Post image

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

5 months ago 3 1 0 0

It's not about the setup, it's about what you get afterwards, if you use the address VO only once, then it doesn't make sense, but if it is crucial in your domain, why not create 1-2 extra classes?

5 months ago 0 0 0 0

This is a great refactoring example!

5 months ago 0 0 0 0
Post image

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

5 months ago 1 0 1 0

The before/after diff made my team actually say "wow." πŸ˜‚ small secrets really.

5 months ago 0 0 0 0
Post image

Collection closures too verbose?

Perfect for:
βœ… Call methods without closures
βœ… Cleaner transformation chains
βœ… Less boilerplate code
βœ… Readable nested access

One line beats five πŸ“

#laravel

5 months ago 1 0 1 0
Post image Post image Post image

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

5 months ago 0 0 0 0
Advertisement

The examples are coming directly from the docs, I love value objects and that one is a good approach ☺️

5 months ago 0 0 1 0
Post image Post image Post image

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

5 months ago 0 0 1 0

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

5 months ago 0 0 0 0
Post image Post image

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

5 months ago 1 0 1 0
Post image

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

5 months ago 1 1 0 0