cedricve / simpleauth
适用于Laravel的简单认证驱动程序
v1.2.2
2017-06-19 12:32 UTC
Requires
- php: >=5.4.0
- illuminate/auth: 5.4.*
This package is not auto-updated.
Last update: 2024-09-28 16:25:54 UTC
README
这是一个简单的认证驱动程序,它使得在app.config文件中定义一个或多个用户成为可能。这对于原型设计项目或者当你没有或不需要数据库时非常有用。此库扩展了原始的Laravel认证驱动程序,因此它使用完全相同的方法。
安装
使用composer安装
composer require cedricve/simpleauth
在app/config/app.php
中添加服务提供者
'Cedricve\Simpleauth\SimpleauthServiceProvider',
服务提供者将为原始认证管理器注册一个扩展。无需注册额外的门面或对象。
配置
在app/config/auth.php
中更改你的默认数据库连接名称
'driver' => 'simple'
并在app/config/app.php
文件中添加一个新属性
'users' => [
[
"id" => 1,
"username" => "root",
"password" => "root",
"firstname" => "Cédric",
"secondname" => "Verstraeten"
...
],
[
"id" => 2,
"username" => "root2",
"password" => "root",
"firstname" => "Cédric",
"secondname" => "Verstraeten"
...
]
],
示例
你可以使用默认的Auth方法。
基本用法
尝试登录
Auth::attempt(['username' => 'root', 'password' => 'root'))
检索已登录的用户
$user = Auth::user();
有关认证的更多信息:https://laravel.net.cn/docs/4.2/security