Dispatch小型的 PHP 框架
Dispatch 是一个小型的 PHP 框架(需要PHP 5.6+)。你可以通过它来定义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) ?>
评论