1. Go to this page and download the library: Download tamce/router 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/ */
tamce / router example snippets
Tamce\Router;
Router::route('/', function () {
echo 'Hello World!';
});
Router::group(['namespace' => 'Controllers'], function () {
Router::get('/register', 'User@register');
Router::get('/user/{username}', 'User@profile');
});
Router::post('/login', 'Controllers\User@login');
// You can also specific a file to load
Router::get('/about', __DIR__ . '/about.php@foo');
Router::route('*', function () {
header('HTTP/1.1 404 Not Found');
echo 'Sorry, the page could not be found!');
});
namespace Controllers;
class User
{
public function register() {...}
public function profile($username) {...}
public function login() {...}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.