1. Go to this page and download the library: Download dannyvankooten/php-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/ */
dannyvankooten / php-router example snippets
PHPRouter\RouteCollection;
use PHPRouter\Router;
use PHPRouter\Route;
$collection = new RouteCollection();
$collection->attachRoute(new Route('/users/', array(
'_controller' => 'someController::usersCreate',
'methods' => 'GET'
)));
$collection->attachRoute(new Route('/', array(
'_controller' => 'someController::indexAction',
'methods' => 'GET'
)));
$router = new Router($collection);
$router->setBasePath('/PHP-Router');
$route = $router->matchCurrentRequest();
var_dump($route);
PHPRouter\RouteCollection;
use PHPRouter\Config;
use PHPRouter\Router;
use PHPRouter\Route;
$config = Config::loadFromFile(__DIR__.'/router.yaml');
$router = Router::parseConfig($config);
$router->matchCurrentRequest();
nginx
server {
listen 80;
server_name mydevsite.dev;
root /var/www/mydevsite/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.