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

Introduction to PHP micro-framework Dispatch_PHP tutorial

WBOY
Release: 2016-07-13 10:28:24
Original
933 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template