Cit*_*zen 5 php api rest standards coding-style
在一个宁静的水果API中,请求假定如下:
api/fruit
api/fruit?limit=100
api/fruit/1
api/fruit?color=red
我认为必须有一个标准的功能来完成这项工作.例如,某些东西可能很容易转化为fruit.class.php.
fruit.class.php
function get ($id, $params, $limit) {
    // query, etc.
}
所以对于我上面的例子,代码看起来像
api/fruit
$fruit = $oFruit->get();
api/fruit?limit=100
$fruit = $oFruit->get(NULL, NULL, 100);
api/fruit/1
$fruit = $oFruit->get(1);
api/fruit?color=red
$fruit = $oFruit->get(NULL, array('color' => 'red'));
有这样的行业标准还是API /数据库功能总是一团糟?我真的很想标准化我的功能.