Coder Social home page Coder Social logo

laravel-api-template's Introduction

About Laravel-Api-Template

随着前后端完全分离,PHP也基本告别了view模板嵌套开发,转而专门写资源接口。Laravel是PHP框架中最优雅的框架,国内也越来越多人选择了LaravelLaravel框架本身对API有支持,但是感觉再工作中还是需要再做一些处理。Lumen用起来不顺手,有些包不能很好地支持。所以,将Laravel框架进行一些配置处理,让其在开发API时更得心应手。 本模板基于Laravel8适配,调整点参考@guaosi大神的项目文档

实现功能

  • 解决跨域问题
  • 统一Response响应处理
  • Api-Resource资源返回
  • 使用Enum枚举
  • jwt-auth用户认证与无感知自动刷新
  • jwt-auth多角色认证不串号
  • 单一设备登陆

环境

  • PHP >= 7.4
  • Laravel8

安装

  1. git clone https://github.com/gedongdong/laravel-api-template
  2. composer install
  3. cp .env.example .env(如需开启单一设备登录登录,设置 SINGLE_DEVICE_LOGIN=true)
  4. php artisan key:generate
  5. php artisan jwt:secret
  6. php artisan migrate
  7. php artisan db:seed

测试数据

users: user1 123456 user2 123456

admins: admin123 123456 admin124 123456

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.