Added namespacing

This commit is contained in:
SteamPixel 2020-01-14 10:42:38 +01:00
parent 6674759d96
commit 545d321e0d
3 changed files with 10 additions and 3 deletions

View File

@ -12,6 +12,7 @@ The third argument will match the request method. The default method is 'get'.
## Simple example: ## Simple example:
```php ```php
use SteamPixel\Route;
include 'Route.php'; include 'Route.php';
Route::add('/user/([0-9]*)/edit', function($id) { Route::add('/user/([0-9]*)/edit', function($id) {

View File

@ -1,4 +1,7 @@
<?php <?php
namespace SteamPixel;
class Route { class Route {
private static $routes = Array(); private static $routes = Array();

View File

@ -1,5 +1,11 @@
<?php <?php
// Use this namespace
use SteamPixel\Route;
// Include router class
include 'Route.php';
function navi() { function navi() {
echo <<<EOD echo <<<EOD
Navigation: Navigation:
@ -23,9 +29,6 @@ function navi() {
EOD; EOD;
} }
// Include router class
include 'Route.php';
// Add base route (startpage) // Add base route (startpage)
Route::add('/', function() { Route::add('/', function() {
navi(); navi();