Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here
Courses

Design Patterns in Laravel 11

Another pattern found extensively in Laravel is the Factory pattern:

use Illuminate\Contracts\Auth\Factory as FactoryContract;
 
class AuthManager implements FactoryContract
{
// ...
}
use Illuminate\Contracts\Mail\Factory as FactoryContract;
 
class MailManager implements FactoryContract
{
// ...
}
use Illuminate\Contracts\Cache\Factory as FactoryContract;
 
class CacheManager implements FactoryContract
{
// ...
}

As you can see, all of these Managers implement the FactoryContract interface (or Factory, as it uses an alias to rename it to FactoryContract).

But what is the Factory pattern?


Factory Pattern

The pattern itself is simple - it is meant for...

This lesson is only for Premium Members.
Want to access all lessons of this course?

You also get:

  • 67 courses (1172 lessons, 43 h 18 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord