# 非关系数据库的自定义用户提供者

刚才描述的用户提供者创建流程仍然依赖于UserProvider类，这意味着它期望从关系数据库中提取标识信息。 但是如果你使用Mongo或Riak或类似的东西，你实际上需要创建自己的类。

要执行此操作，你需要创建一个实现Illuminate\Contracts\Auth \UserProvider接口的类，然后将其绑定到AuthServiceProvider\@boot

```php
auth()->provider('riak', function ($app, array $config) {
    // Return an instance of Illuminate\Contracts\Auth\UserProvider... 
    return new RiakUserProvider($app['riak.connection']);
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/yong-hu-ren-zheng-yu-shou-quan/shou-wei/fei-guan-xi-shu-ju-ku-de-zi-ding-yi-yong-hu-ti-gong-zhe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
