基于Laravel Passport
实现OAuth2.0
授权 封装Resource
完成统一API
$ cp .env.example .env
$ composer install
$ php artisan migrate
数据库连接配置开发环境
$ php artisan passport:install
$ php artisan passport:client --password --name='apkbus-ios'
$ php artisan thinker
$ namespace App\Models;
$ factory(User::class,10)->create();
{
"status": "success",
"code": 200,
"message": "请求成功"
}
{
"status": "error",
"code": 401,
"message": "用户认证失败"
}
{
"data": {
"id": 1,
"name": "Joshua Torphy",
"email": "napoleon10@example.net",
"created_at": "2019-04-19 06:48:00"
}
}
{
"data": {
"list": [
{
"id": 1,
"name": "Joshua Torphy",
"email": "napoleon10@example.net",
"created_at": "2019-04-19 06:48:00"
},
{
"id": 2,
"name": "Yessenia Ebert PhD",
"email": "ignatius87@example.com",
"created_at": "2019-04-19 06:48:00"
},
{
"id": 3,
"name": "Dr. Samson Rath IV",
"email": "kortiz@example.net",
"created_at": "2019-04-19 06:48:00"
},
{
"id": 4,
"name": "Julien Swift",
"email": "laurie43@example.net",
"created_at": "2019-04-19 06:48:00"
}
],
"count": 4
},
"links": {
"first": "http://laravel-passport.site/api/users?page=1",
"last": "http://laravel-passport.site/api/users?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "http://laravel-passport.site/api/users",
"per_page": 15,
"to": 4,
"total": 4
}
}