https://www.kancloud.cn/manual/thinkphp5/118035
image.png准备工作
image.pngconfig.php
<?php
/**
* Created by PhpStorm.
* User: tong
* Date: 2017/11/15
* Time: 10:21
*/
return[
'default_return_type'=>'json',
];
route.php
<?php
use think\Route;
Route::get('test', 'api/test/index');
Route::put('test/:id', 'api/test/update');
Route::delete('test/:id', 'api/test/delete');
Route::resource('test','api/test');//查看手册对应方法
//post =>api/test/ save
Test.php
<?php
/**
* Created by PhpStorm.
* User: tong
* Date: 2017/11/15
* Time: 10:23
*/
namespace app\api\controller;
use think\Controller;
class Test extends Controller
{
public function index()
{
return [
'sgsg',
'sgsgs',
];
}
public function update($id = 0)
{
//return $id;//http://singwa.com/test/100
halt(input('put.'));//body提交
}
public function save()
{
return input('post.');
}
}
网友评论