Git Product home page Git Product logo

thinkphp-custom's Introduction

基于tp5框架的API项目设计

框架设计构造

  • 加入服务容器(pimple\container),解决依赖注入和单例化。(若不设计服务容器,采用tp自身的依赖注入)。

  • 新增service层:封装业务处理相关类。

  • 新增model层(继承了tp5的模型):封装公共常用方法、tp5的数据库操作和tp5的模型。

  • 解决接口请求时抛出异常信息的捕获,将html的格式输出修改为json格式输出。

  • API接口响应码和返回数据格式的定义。

  • API接口请求header头部新增Auth-Token处理非法请求,Auth-Token生成逻辑的定义和校验处理。

  • API接口版本的设计使用 git tag 打标签的方式,线上部署各个版本代码。(TODO:web服务器的配置)

  • 配置tp5的config配置文件的auth->except参数,定义不需要接口安全验证的controller名称。

  • 密码的验证逻辑

构造设计的功能测试部署

  • 自定义Command命令

    • php think test {{post_id}}
  • 接口

    • post实体的read、list、save、update和delete的接口
    • comment实体的Service
    • user实体的login、logout和register接口

设计构造接口自动化测试

  • debug模式下接口自动化测试(建立测试环境db和redis)

  • 增加post文章和user用户的两个测试

  • 执行测试

    • 前提:由于测试
    • vendor/bin/codecept run api

thinkphp-custom's People

Contributors

chenbo29 avatar

Watchers

 avatar

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.