Skip to main content

What is Manager?

Illuminate\Support\Manager is an abstract class that has existed since Laravel 4.0. It provides the foundation for building systems that can switch between multiple “drivers” — cache backends, session stores, mail transports, and so on. A “driver” is a backend implementation that satisfies the same interface while using a different underlying technology. For sessions, the available drivers are file, cookie, database, and redis. The active driver is chosen by a single driver key in the configuration file.

Which classes use Manager?

Not every class with “Manager” in its name extends Illuminate\Support\Manager. Some provide their own equivalent implementation. Classes that do not extend Manager still follow the same extend() pattern conceptually. Understanding the Manager class therefore gives you a mental model that applies across the entire framework.

How it works

driver() — resolving a driver

Calling driver() follows this sequence: The driver name is converted to a method name using Str::studly().
So the file driver maps to createFileDriver(), and a driver named my-custom maps to createMyCustomDriver().

extend() — registering a custom driver

Pass a driver name and a closure to extend() to register a custom driver. The closure receives the container instance.
extend() binds the closure to $this (the manager), so you can access the manager’s properties and methods from inside the closure.

__call — proxying to the default driver

Manager implements __call, so any method call that does not exist on the manager itself is forwarded to the default driver automatically.
This is how SessionManager::get('key') works — you call the method on the manager, and it is transparently delegated to the active session driver.

SessionManager as a reference implementation

Illuminate\Session\SessionManager shows the full pattern in practice.

Building a custom Manager

Here is a notification service example.
1

Extend Manager

2

Register in a service provider

3

Add a custom driver at runtime

4

Use it

MultipleInstanceManager

Illuminate\Support\MultipleInstanceManager was added in Laravel 10. Where Manager manages driver types (like file or redis), MultipleInstanceManager manages named instances — multiple independently configured instances of the same logical resource.

Comparison with Manager

Required methods

Three abstract methods must be implemented.
getInstanceConfig() must return an array that includes a driver key (or whatever key $driverKey is set to).

Resolution flow

Example: an SMS gateway package

This example shows a manager that supports multiple independently configured SMS gateways.
The corresponding configuration file:
You select an instance by name using instance().
MultipleInstanceManager supports extend() and __call in the same way as Manager. Unknown method calls are forwarded to the default instance automatically.

Managing the driver cache

Manager

MultipleInstanceManager

Summary

  • Manager manages driver types. Implement createXxxDriver() methods and use extend() to add new ones.
  • MultipleInstanceManager manages named instances. Use it when a package needs to support multiple independently configured connections.
  • Not every “Manager” class in Laravel extends Illuminate\Support\Manager. CacheManager and QueueManager are notable exceptions with their own implementations.

The Macroable trait

Learn how to add custom methods to existing Laravel classes using the Macroable trait.
Last modified on July 13, 2026