PHP code example of peterujah / php-router-template
1. Go to this page and download the library: Download peterujah/php-router-template 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/ */
peterujah / php-router-template example snippets
$template = new \Peterujah\NanoBlock\RouterTemplate(__DIR__, false);
$template->addUser(new User(User::LIVE))->addFunc(new Functions())->addConfig(new Config());
$router->get('/', function() use ($template) {
$template->Build("home")->with($template->deep(0));
});
$router->get('/', function() use ($template) {
$template->Build("home")->view(0);
});
$router->get('/update/([a-zA-Z0-9]+)', function($id) use ($template) {
$template->Build("product")->view(1);
/*
Using with method below
$template->Build("product")->with($template->deep(1));
*/
});
$router->get('/update/([a-zA-Z0-9]+)', function($id) use ($template) {
$template->Build("product")->view(1, [
"foo" => "Our Foo"
"bar" => "Our Bar id {$id}"
]);
});
/*Secure template from unwanted access*/
$ALLOW_ACCESS or die("Access Denied");
md
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.