dyweb / course

Dongyue Web Studio course and lecture
https://dongyueweb.com/course/
GNU General Public License v3.0
12 stars 3 forks source link

Resfful API Assignment Hand in #19

Closed tripack45 closed 7 years ago

tripack45 commented 8 years ago

An Todo List API. Repo: tripack45/dyhw, On "hw2" branch. Testing Server Address: http://59.78.36.78:8080/hw2/api/v1/tasks Built upon Slim framework. The app is roughly MVC structured. Data are stored using MySQL. Did some protection :-); Don't know if the API is correctly "RESTed". Any help will be appreciated!

Detailed usage is in the readme file in that branch.

at15 commented 8 years ago

\w/ I will have a look if I can finish my thesis project & paper ..... aka: 我只是过来冒个泡的

然后还是忍不住吃饭前看了一下

https://github.com/tripack45/dyhw/blob/hw2/src/index.php#L5 it is recommended not to track vendor folder, but where is your composer.json ???

tripack45 commented 8 years ago

@at15 我自己把Composer Dependence当做所有的Homework的公共内容,所以就没有。Dependence话就是 Slim。没有别的Dependence

at15 commented 8 years ago

那这样的话可以把controller里的req和res加上类型限定 https://github.com/tripack45/dyhw/blob/hw2/src/controller.php#L18 ie: https://github.com/at15/bform/blob/master/app/Controller/Token.php#L27

tripack45 commented 8 years ago

Done. 为啥加上类型限定会更好?还有这种检查API参数是否合法,不合法报错这种应该算MVC中的哪一层?

at15 commented 8 years ago

@tripack45 加上类型限定IDE会有更好的提示,当然对目前的PHP性能并没有提升。你说检查参数是否合法是指加类型限定么?这里在运行时不应该出现报错,因为调用你controller的是框架。 如果你指的是检查用户传的id是否是整数之类的话,是在controller层。