
微信截图_20171122142221.png
route.php
<?php
use think\Route;
Route::get('test', 'api/test/index');
Route::put('test/:id', 'api/test/update');
Route::resource('test', 'api/test');
Route::get('api/:ver/cat', 'api/:ver.cat/read');
Cat.php
<?php
/**
* Created by PhpStorm.
* User: tong
* Date: 2017/11/22
* Time: 11:09
*/
namespace app\api\controller\v1;
use app\api\controller\Common;
class Cat extends Common
{
public function read()
{
$cats = config('cat.list');
/**
* array (size=4)
* 1 => string '综艺' (length=6)
* 2 => string '明星' (length=6)
* 3 => string '韩娱' (length=6)
* 4 => string '看点' (length=6)
*/
//halt($cats);
$result []= [
'catid'=>0,
'catname'=>'首页',
];
foreach ($cats as $catid => $catname) {
$result[] = [
'catid' => $catid,
'catname' => $catname,
];
}
return show(config('code.success'), 'OK', $result, 200);
}
}
namespace app\api\controller\v1;
use app\api\controller\Common;

image.png
网友评论