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:

  • 63 courses (1128 lessons, 42 h 01 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord