作者swallowcc (罹患重度能年病的燕叔)
看板PHP
標題[請益] Codeigniter restful api
時間Thu Jun 16 14:06:40 2016
不好意思想請問一個蠢問題...
我現在有一隻 api.php 在負責 rest webservice 的運作.
(用的是這個
https://github.com/chriskacerguis/codeigniter-restserver )
寫到現在幾千行了,覺得有點雜亂無章,想要把裡面的 api 依照功能分開整理一下。
不過這時才發現,
我不曉得要怎麼讓 api 寫在其他 php 檔案再 include 進來... orz
且, 因為也灑了一些對應裝置出去了, 所以入口一定得是 api.php 了...
有人可以教學一下, 該怎麼處理這個肥大的檔案嗎 囧rz
感恩<(_ _)>
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.163.31.80
※ 文章網址: https://webptt.com/m.aspx?n=bbs/PHP/M.1466057204.A.0AA.html
1F:→ dou0228: 先配合 URL rewrite 把 API 分開來 06/16 15:24
2F:→ MOONRAKER: 在route裡面就分開吧 例如/api/users送這一隻 06/16 16:22
3F:→ MOONRAKER: /api/events送別隻這樣 06/16 16:22
了解,所以一定要從route面處理,沒辦法從檔案面就是了 ~ 感恩以上大德 orz
※ 編輯: swallowcc (1.163.31.80), 06/16/2016 16:33:58
4F:→ MOONRAKER: 也是可以用url helper啦 可是route應該是比較方便 06/16 18:37
5F:→ xdraculax: 也可以用 _remap 06/17 15:42
6F:推 mikejaffson: CI有MVC架構,依照你的需求先將流程跟業務邏輯分離寫 06/20 03:06
7F:→ mikejaffson: 到Controller跟Model,再將會reuse卻不適合放在Model 06/20 03:06
8F:→ mikejaffson: 的考慮放在helper或library 06/20 03:06
9F:推 ej04cj86: Api response絕對要用transformer interface/abstract c 07/18 06:13
10F:→ ej04cj86: lasses阿 07/18 06:13