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?
The pattern itself is simple - it is meant for...