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 Statamic\Facades\User::repository() method to define a custom repository driver:

Statamic\Facades\User::repository('custom', function ($app, $config) {
    return new CustomUserRepository;
});

After you’ve registered the driver using the repository 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'
Betterify this page on Github!