This design pattern aims to gain simpler, reusable objects. Its goal is to separate bigger and more convoluted object construction layers from the rest so that the separated layers can be used in different layers of the application.
In Laravel, the AuthManager
class needs to create some secure elements to reuse with selected auth storage drivers such as cookie, session, or custom elements. To achieve this, the AuthManager
class needs to use storage functions such as callCustomCreator()
and getDrivers()
from the Manager
class.
Let's see how the Builder (Manager) pattern is used in Laravel. To see what happens in this pattern, navigate to the vendor/Illuminate/Support/Manager.php
and vendor/Illuminate/Auth/AuthManager.php
files, as shown in the following code:
public function driver($driver = null) { ... } protected function createDriver($driver) { $method = 'create'.ucfirst($driver).'Driver...