小型的 PHP 框架:Dispatch
Dispatch 是一個小型的 PHP 框架(至少 PHP 5.4)。你可以通過它來定義URL規則和方法,以便更好組織應用程序。非常適合 API、簡單的站點或原型開發。
提供的方法:
<?php // routing functions function on($method, $path, $callback) function resource($name, $cb) function error($code, $callback = null) function before($callback) function after($callback) function filter($symbol, $callback) function redirect($path, $code = 302, $condition = true) // views, templates and responses function render($view, $locals = null, $layout = null) function partial($view, $locals = null) function json_out($obj, $func = null) function nocache() // request data helpers function params($name = null, $default = null) function cookie($name, $value = null, $expire = 0, $path = '/') function scope($name, $value = null) function upload($name) function download($path, $filename, $sec_expire = 0) function request_headers($name = null) function request_body() // configurations and settings function config($key, $value = null) function site($path_only = false) // misc helpers function flash($key, $msg = null, $now = false) function u($str) function h($str, $flags = ENT_QUOTES, $enc = 'UTF-8') function ip() // entry point function dispatch($method = null, $path = null) ?>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!