-
-
Notifications
You must be signed in to change notification settings - Fork 49
2. Getting Started
İzni Burak Demirtaş edited this page Aug 21, 2018
·
8 revisions
composer.json file:
{
"require": {
"izniburak/router": "^1"
}
}
after run the install command.
$ composer install
OR run the following command directly.
$ composer require izniburak/router
require 'vendor/autoload.php';
$router = new \Buki\Router();
$router->get('/', function() {
return 'Hello World!';
});
$router->run();
And add this code to the .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Congratulations! Now, you can use PHP-Router.
If you have a problem, you can contact me or open new issue.
If you would like define paths and namespaces for Controllers and Middlewares, you can do this at below:
require 'vendor/autoload.php';
$router = new \Buki\Router([
'paths' => [
'controllers' => 'Controllers',
'middlewares' => 'Middlewares',
],
'namespaces' => [
'controllers' => 'App\\Controller',
'middlewares' => 'App\\Middlewares',
]
]);
$router->get('/', function() {
return 'Hello World!';
});
$router->run();