_____ _ _ _____ _____ _
| __ \| | | | __ \ | __ \ | |
| |__) | |__| | |__) | ______ | |__) |___ _ _| |_ ___ _ __
| ___/| __ | ___/ |______| | _ // _ \| | | | __/ _ \ '__|
| | | | | | | | | \ \ (_) | |_| | || __/ |
|_| |_| |_|_| |_| \_\___/ \__,_|\__\___|_|
PHP Router, which also has rich features like Middlewares and Controllers is simple and useful router class for PHP.
symfony/http-foundation
package.To install PHP Router, You can run the following command directly at your project path in your console:
$ composer require izniburak/router
OR you can add following lines into the composer.json
file manually:
{
"require": {
"izniburak/router": "^2.0"
}
}
Then, run the following command:
$ composer install
require 'vendor/autoload.php';
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();
Documentation page: Buki\Router Docs
Changelogs: Buki\Router Changelogs