Skip to content

Conversation

@hosni
Copy link
Contributor

@hosni hosni commented Jan 4, 2026

This PR adds support for using PHP enums (UnitEnum and BackedEnum) as driver identifiers in Illuminate\Support\Manager.

Managers can now accept enums in driver(), extend(), and getDefaultDriver(). Driver names are normalized via enum_value(), while internal caching and resolution continue to operate on strings.

This applies to all managers extending Illuminate\Support\Manager, including:

  • Illuminate\Foundation\MaintenanceModeManager
  • Illuminate\Hashing\HashManager
  • Illuminate\Notifications\ChannelManager
  • Illuminate\Session\SessionManager

Example:

use Illuminate\Support\Facades\Session;

enum SessionDriver: string
{
    case Database = 'database';
}

Session::driver(CacheDriver::Redis)->put('key', 'value');

BC

  • No breaking changes
  • Existing string-based usage unchanged
  • Driver caching and extension behavior preserved

Integration tests added for enum defaults, enum extensions, mixed enum and string drivers, and caching behavior.

@hosni hosni force-pushed the support-enum-in-managers branch from 36d2f7d to 1b2407f Compare January 4, 2026 12:12
@hosni hosni force-pushed the support-enum-in-managers branch from 1b2407f to 04f2189 Compare January 4, 2026 12:13
@hosni hosni changed the title [12.x] Support enums as driver identifiers in Illuminate\Support\Manager [12.x] Support enums as driver in Illuminate\Support\Manager Jan 4, 2026
@taylorotwell
Copy link
Member

Don't make a resolveDriverName method

@taylorotwell taylorotwell marked this pull request as draft January 4, 2026 17:17
@hosni
Copy link
Contributor Author

hosni commented Jan 4, 2026

Don't make a resolveDriverName method

Done. I’ve removed the resolveDriverName method and inlined enum_value() where needed.

@hosni hosni marked this pull request as ready for review January 4, 2026 17:34
@hosni hosni force-pushed the support-enum-in-managers branch from 8fa2a3b to b9aab6d Compare January 5, 2026 08:14
@taylorotwell
Copy link
Member

I think you would also need to update MultipleInstanceManager.

@taylorotwell taylorotwell marked this pull request as draft January 5, 2026 16:21
@hosni
Copy link
Contributor Author

hosni commented Jan 6, 2026

I think you would also need to update MultipleInstanceManager.

Sure, I’ll update MultipleInstanceManager as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants