1. Go to this page and download the library: Download jameslevi/dispatcher 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/ */
jameslevi / dispatcher example snippets
// Make a new router instance.
$router = new Graphite\Component\Dispatcher\Dispatcher();
// Execute callback each time error occurs.
$router->onError(function($request) {
});
// Register middleware #1.
$router->middleware(function($request) {
});
// Register middleware #2.
$router->middleware(function($request) {
});
// Register route #1.
$router->get("/", function($request) {
return "Home";
});
// Register route #2.
$router->post("/register", function($request) {
return "Register";
});
// Register after middleware #1.
$router->afterMiddleware(function($request) {
});
// Execute callback each time request ends.
$router->onDestroy(function($request) {
});
// Run your application.
$router->run();
namespace App\Controller;
class MyController {
public function home($request) {
return "Home";
}
public function aboutUs($request) {
return "About Us";
}
}