1. Go to this page and download the library: Download maplephp/handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maplephp / handler example snippets
$routes->group("[POSSIBLE_PATTERNS]", function($routes) {
// Router data - will inherit the group pattern and middlewares
$routes->get("[PATTERN]", ['CLASS', "METHOD"]);
// You can nest groups in infinity
$routes->group(function($routes) {
// Router data - will inherit group and group parents patterns and middlewares
$routes->get("[PATTERN]", ['CLASS', "METHOD"]);
$routes->post("[PATTERN]", ['CLASS', "METHOD"]);
}, [
[Http\Middlewares\LoggedIn::class, "privateZone"],
]);
}, [
[
Http\Middlewares\SessionStart::class,
Http\Middlewares\DomManipulation::class
]
]);
// Catch a GET response
$routes->get("/{page:about}", ['Http\Controllers\Pages', "about"]);
// Catch a POST response
$routes->post("/{page:about}", ['Http\Controllers\Pages', "about"]);
// Catch a PUT response
$routes->put("/{page:about}", ['Http\Controllers\Pages', "about"]);
// Catch a DELETE response
$routes->delete("/{page:about}", ['Http\Controllers\Pages', "about"]);
// Catch a Custom response
$routes->map("CLI","/{page:about}", ['Http\Controllers\Pages', "about"]);
// Catch a Multiple responses
$routes->map(["GET", "POST"],"/{page:about}", ['Http\Controllers\Pages', "about"]);
// Take control over all the HTTP request errors (404, 403...). If removed, MaplePHP will generically try to handle the error responses.
$routes->map("*", '[/{any:.*}]', ['Http\Controllers\HttpRequestError', "handleError"]);
// Group
$routes->group("/{lang:en}", function($routes) {
$routes->get("/{page:about}", ['Http\Controllers\Pages', "about"]);
$routes->get("/{page:contact}", ['Http\Controllers\Pages', "contact"]);
});
// Group under language /en
$routes->group("/{lang:en}", function($routes) {
$routes->get("/{page:about}", ['Http\Controllers\Pages', "about"]);
$routes->get("/{page:contact}", ['Http\Controllers\Pages', "contact"]);
});
// Group under language all possible languages
$routes->group("/{lang:[^/]+}", function($routes) {
$routes->get("/{page:about}", ['Http\Controllers\Pages', "about"]);
$routes->get("/{page:contact}", ['Http\Controllers\Pages', "contact"]);
});
$routes->group(function($routes) {
$routes->get("/{form:login}", ['Http\Controllers\Users\Login', "form"]);
// You can nest groups in infinity
$routes->group(function($routes) {
// Router data - will inherit group and group parents patterns and middlewares
$routes->get("/{profile:profile}", ['Http\Controllers\Examples\PrivatePage', "profile"]);
}, [
[Http\Middlewares\LoggedIn::class, "privateZone"]
]);
}, [
Http\Middlewares\SessionStart::class,
Http\Middlewares\DomManipulation::class
]);
$routes->group(function($routes) {
// Will handle all HTTP request errors
$routes->map("*", '[/{any:.*}]', ['Http\Controllers\HttpRequestError', "handleError"]);
// Your routes
$routes->get("/", ['Http\Controllers\Examples\Pages', "start"]);
$routes->get("/{page:about}", ['Http\Controllers\Examples\Pages', "about"]);
$routes->group(function($routes) {
// Regular page with form
$routes->get("/{form:login}", ['Http\Controllers\Users\Login', "form"]);
// Open form in a modal with ajax call
$routes->get("/{form:login}/{model:model}", ['Http\Controllers\Users\Login', "formModel"]);
// Login request
$routes->post("/{form:login}", ['Http\Controllers\Users\Login', "login"]);
}, [
[Http\Middlewares\LoggedIn::class, "publicZone"],
]);
$routes->group(function($routes) {
// Will handle all HTTP request errors
$routes->get("/{profile:profile}", ['Http\Controllers\Examples\PrivatePage', "profile"]);
}, [
[Http\Middlewares\LoggedIn::class, "privateZone"]
]);
}, [
Http\Middlewares\SessionStart::class,
Http\Middlewares\DomManipulation::class
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.