Home  >  Article  >  Backend Development  >  Introduction to PHP micro-framework Dispatch_PHP tutorial

Introduction to PHP micro-framework Dispatch_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:28:24882browse

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!

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn