Introduction to PHP Micro Framework Dispatch
- 2021-06-29 10:31:22
- OfStack
Dispatch is an PHP framework.It does not give you complete MVC settings, but you can define URL rules and methods to better organize your applications.This is perfect for API, simple sites, or prototypes.
You can match specific types of HTTP requests and paths, render the view, or do more.If you combine Dispatch with other frameworks, you can have a fairly powerful and lightweight program!
// Include Library
include 'dispatch.php';
// Define your route
get('/greet', function () {
// Render view
render('greet-form');
});
//post Handle
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 the view, or do more.If you combine Dispatch with other frameworks, you can have a fairly powerful and lightweight program!