1. Go to this page and download the library: Download lablnet/zestrouter 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/ */
lablnet / zestrouter example snippets
use Lablnet\ZestRouter;
mespaces uses for loading controllers olny
//$router->setDefaultNamespace("App\Controllers\\");
$router->get('', function () {
echo 'Example route using closure';
});
/*
//OR
$router->add('', function () {
echo 'Example route using closure';
},'GET');
*/
$router->get('test','Home@index');
/*
//OR
$router->get('test',['controller' => 'Home', 'action' => 'index']);
//OR
$router->add('test',['controller' => 'Home', 'action' => 'index'],'GET');
*/
//Dispatch/Process the request automatically for mannually dispatch request take a look at Process Request section
$router->dispatch($_SERVER['QUERY_STRING']);
$router->add('', function () {
echo "Welcome";
},'GET');
$router->get('', function () {
echo "Welcome";
});
//Add the routes
$router->get('', function () {
echo 'Example route using closure';
});
$router->get('user/{id:\d+}', function ($args) {
echo 'Example route using closure with params id: ' .$args['id'];
});
// match current request url
$match = $router->customDispatch();
if ($match && is_callable( $match['callable'] )) {
call_user_func( $match['callable'], $match );
} else {
// no route was matched
echo '404 Not Found';
}
location / {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/(.*)$ /index.php?$1 last;
}
}
php
$match = $router->customDispatch();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.