Skip to content

Controller

axios edited this page Oct 8, 2020 · 5 revisions

Get details from the \tpr\Controller code.

Usage

Provide inheritance to controller subclasses

namespace app\index\controller;

use tpr\Controller;

class Index extends Controller
{
    public function index()
    {
        $this->response(["hello, world!"]);
    }
}
  • return normal reponse
$this->response($result = '', $status = 200, $msg = '', array $headers = []);
  • return success response
$this->success($data = []);
  • return error response
$this->error($code = 500, $msg = 'error');
  • return html content

more detail in Views document

return $this->fetch(string $template = '', array $vars = []);
  • redirect
$this->redirect(string $destination, bool $permanent = true);
Clone this wiki locally