# scale **Repository Path**: rafikingkong/scale ## Basic Information - **Project Name**: scale - **Description**: xq_scale - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-01-17 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xiaoqiao bodyfat scale lumen 5.3 写的 Lumen + dingo api + jwt + ## USEFUL LINK 读文档很重要,请先仔细读读 dingo/api,jwt,fractal 的文档。 - dingo/api [https://github.com/dingo/api](https://github.com/dingo/api) - dingo api 中文文档 [dingo-api-wiki-zh](https://github.com/liyu001989/dingo-api-wiki-zh) - json-web-token(jwt) [https://github.com/tymondesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth) - transformer [fractal](http://fractal.thephpleague.com/) - apidoc 生成在线文档 [apidocjs](http://apidocjs.com/) - rest api 参考规范 [jsonapi.org](http://jsonapi.org/format/) - api 调试工具 [postman](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en) - 参考文章 [http://oomusou.io/laravel/laravel-architecture](http://oomusou.io/laravel/laravel-architecture/) - 该项目api文档 [http://lumen.lyyw.info/apidoc](https://lumen.lyyw.info/apidoc) ## USAGE ``` $ git clone git@github.com:liyu001989/lumen-api-demo.git $ composer install $ cp .env.example .env $ vim .env DB_* 填写数据库相关配置 your database configuration JWT_SECRET php artisan jwt:secret APP_KEY lumen 取消了key:generate 所以随便找个地方生成一下吧 md5(uniqid()),str_random(32) 之类的,或者用jwt:secret生成两个copy一下 $ php artisan migrate $ php artisan db:seed (默认添加了10个用户,50篇帖子, 100调评论) $ 生成文档我是这么写的 apidoc -i app/Http/Controllers/Api/V1 -o public/apidoc $ api文档在public/apidoc里面, 也可以看上面的 `在线api文档` ``` 如果访问一直不对,可以进入public 目录执行`php -S localhost:8080`,然后尝试调用几个接口,从而确定是否为web服务器的配置问题。 ## REST API DESIGN 大概举个例子说明一下 rest api 吧 github 的 api 真的很有参考价值 [github-rest-api](https://developer.github.com/v3/) 例子: 用户,帖子,评论 get /api/posts 帖子列表 post /api/posts 创建帖子 get /api/posts/5 id为5的帖子详情 put /api/posts/5 替换帖子5的全部信息 patch /api/posts/5 修改部分帖子5的信息 delete /api/posts/5 删除帖子5 get /api/posts/5/comments 帖子5的评论列表 post /api/posts/5/comments 添加评论 get /api/posts/5/comments/8 id为5的帖子的id为8的评论详情 put /api/posts/5/comments/8 替换帖子评论内容 patch /api/posts/5/comments/8 部分更新帖子评论 delete /api/posts/5/comments/8 删除某个评论 get /api/users/4/posts id为4的用户的帖子列表 get /api/user/posts 当前用户的帖子列表 ## 问题总结 ## TODO - [ ] 单元测试 ## 坑 - [https://github.com/dingo/api/issues/672](https://github.com/dingo/api/issues/672) `transformer include` - 如果 .env 的某个值中有空格会报错 log not found。env 中的值有空格需要引号包裹 ## License [MIT license](http://opensource.org/licenses/MIT)