PHP code example of jsnlib / rest_controller
1. Go to this page and download the library: Download jsnlib/rest_controller library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsnlib / rest_controller example snippets
class MY_APP_Controller extends \Jsnlib\Codeigniter\REST_Controller
{
// 一些共用程式碼
}
class User extends MY_APP_Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
}
}
// 若成功,不使用 $data 參數,會自動使用 ['status' => true]
$result = \Jsnlib\Codeigniter\REST_Controller::success($data = false);
parent::respary($result);
// 若失敗
return \Jsnlib\Codeigniter\REST_Controller::error($code, $message, $data = false);
parent::respary($result);