Dispatch 是一个小型的 PHP 框架(至少 PHP 5.4)。你可以通过它来定义URL规则和方法,以便更好组织应用程序。非常适合 API、简单的站点或原型开发。
示例代码:
<?php// routing Functionsfunction on($method, $path, $callback)function resource($name, $cb)function before($callback)function after($callback)function redirect($path, $code = 302, $condition = true)// vIEws, templates and responsesfunction render($view, $locals = null, $layout = null)function partial($view, $locals = null)function nocache()// request Data helpersfunction 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 settingsfunction config($key, $value = null)function site($path_only = false)// misc helpersfunction u($str)function h($str, $flags = ENT_QUOTES, $enc = 'UTF-8')function ip()// entry POIntfunction dispatch($method = null, $path = null)?>发布于 2015-02-01 06:53:44 | 229 次阅读