Giter VIP home page Giter VIP logo

laravel-api-starter's Introduction

laravel-api-starter

这是一个 Laravel 5.5 + Dingo + JWT 的基础项目, 用于快速开始写 API

StyleCI License donate donate

  • Laravel/RESTful 交流群: 216721539

USEFUL LINK

读文档很重要,请先仔细读读文档 laravel, dingo/api,jwt,fractal 的文档。

USAGE

$ git clone [email protected]:liyu001989/laravel-api-starter.git
$ composer install
$ 设置 `storage` 目录必须让服务器有写入权限。
$ cp .env.example .env
$ vim .env
    DB_*
        填写数据库相关配置 your database configuration
    APP_KEY
        php artisan key:generate
    JWT_SECRET
        php artisan jwt:secret

$ php artisan migrate
$ php artisan db:seed (默认添加了10个用户)

头信息中可以增加 Accept:application/vnd.app.v1+json 切换v1和v2版本

如果访问一直不对,可以进入public 目录执行 php -S localhost:8000 -t public,然后尝试调用几个接口,从而确定是否为web服务器的配置问题。

相关说明

  • 通过一个中间件 https://github.com/liyu001989/dingo-serializer-switch 切换 fractal 的 serializer, 默认使用 array。
  • 让 findOrFail 返回 404, 更方便使用
  • 可以用过 Accept-Language 头来却换语言,比如 zh-CN, 当然也可以默认中文

License

MIT license

laravel-api-starter's People

Contributors

liyu001989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-api-starter's Issues

请问JsonResponse是从哪里指定的

我发现在控制器里不使用dingo/apiresponse方法的话,会默认返回JsonResponse
比如这样

return array('test');

会返回

Illuminate\Http\JsonResponse

那么如果我不想用

return $this->response->array('test');

这种方法,还想返回response类,需要怎么设置呢。

I found a bug in .env.example.

Thanks for your project! It helps me a lot. However, I think I might find a bug in the .env.example file.

`JWT_SECRET=

一天过期,一周可刷新

JWT_TTL=86300
JWT_REFRESH_TTL=20160`

I believe the JWT_TTL is supposed to be 1440, instead of 86300, since this param is measured by minutes, not seconds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.