Dispatch is a small PHP framework. It doesn't give you a complete MVC setup, but you can define URL rules and methods to better organize your application. This is perfect for APIs, simple sites or prototypes.
Copy code The code is as follows:
//Include library
include 'dispatch.php';
//Define your route
get('/greet', function () {
//Render view
render('greet-form');
});
//post processing
post('/greet', function () {
$name = from($_POST, 'name');
// render a view while passing some locals
render ('greet-show', array('name' => $name));
});
// serve your site
dispatch();
You can match specific types of HTTP requests and paths, render views or do more. If you combine Dispatch with other frameworks, you can have a very powerful and lightweight program!
http://www.bkjia.com/PHPjc/788640.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/788640.htmlTechArticleDispatch is a small PHP framework. It doesn't give you a complete MVC setup, but you can define URL rules and methods to better organize your application. This is great for APIs, simple sites or prototypes...