PHP code example of izniburak / router
1. Go to this page and download the library: Download izniburak/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/ */
izniburak / router example snippets
use Buki\Router\Router;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new Router;
// For basic GET URI
$router->get('/', function(Request $request, Response $response) {
$response->setContent('Hello World');
return $response;
# OR
# return 'Hello World!';
});
// For basic GET URI by using a Controller class.
$router->get('/test', 'TestController@main');
// For auto discovering all methods and URIs
$router->controller('/users', 'UserController');
$router->run();