Skip to content

Latest commit

 

History

67 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaravelAPI

StyleCi License Development Version Monthly Installs PHP laravel

快速构建laravel api服务

1.安装

$ composer require jasonc/api

$ php artisan api:install

$ php artisan vendor:publish

2.使用

return $this->message(string $message);
return $this->success(array $data);
return $this->failed(string $error);

3.修改 App\Exceptions\Handler 文件,引入Trait

<?php

namespace App\Exceptions;

use Jason\Api\Traits\ApiException;

class Handler extends ExceptionHandler
{

    use ApiException;
}

4.身份认证

修改User模型

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Jason\Api\Traits\ApiGuardable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class User extends Authenticatable implements JWTSubject 
{

    use ApiGuardable;
}


About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages