Storing Users Somewhere Custom

Sometimes you just gotta be special.

If you'd like to store your users somewhere outside the filesystem, and the included Eloquent implementation doesn't quite cut it for you,
you're free to write your own.

You will need to write implementations for all the contracts located in Statamic\Contracts\Auth. Of course, you may extend the native classes and override where appropriate, instead of writing everything from scratch.

In a service provider, use the extend method on the UserRepositoryManager to define a custom repository driver:

app(\Statamic\Auth\UserRepositoryManager::class)->extend('custom', function ($app, $config) {
return new CustomUserRepository;
});

After you've registered the driver using the extend method, you'll want to create a repository in config/statamic/users.php that uses the new driver:

'repositories' => [
'custom' => [
'driver' => 'custom',
]
]

Finally, set that repository as the one you want active:

'repository' => 'custom'
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →