1. Go to this page and download the library: Download gnf/namespace-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/ */
gnf / namespace-router example snippets
# \AnyNamespace\RootController
# request '/' => 'root'
class RootController implements ControllerProviderInterface
{
public function connect(ControllerCollection $controller_collection)
{
$controller_collection = $app['controllers_factory'];
$controller_collection->get('/', function () {
return new Response('root');
});
return $controller_collection;
}
}
# \AnyNamespace\Blog
# request '/Blog/View' => 'blog view'
class Blog implements ControllerProviderInterface
{
public function connect(ControllerCollection $controller_collection)
{
$controller_collection = $app['controllers_factory'];
$controller_collection->get('/View', [$this, 'View']);
return $controller_collection;
}
public function view()
{
return new Response('blog view');
}
}
# \AnyNamespace\Site\Admin
# request '/Site/Admin/View' => 'admin view'
class Admin implements ControllerProviderInterface
{
public function connect(ControllerCollection $controller_collection)
{
$controller_collection = $app['controllers_factory'];
$controller_collection->get('/View', [$this, 'View']);
return $controller_collection;
}
public function view()
{
return new Response('admin view');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.