diff --git a/.htaccess b/.htaccess index 2c377a9..d7e1320 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,3 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule . index.php [L] \ No newline at end of file +RewriteRule . index.php [L] diff --git a/AltoRouter.php b/AltoRouter.php index c8bc6f4..8103dd3 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -23,18 +23,18 @@ class AltoRouter { * */ public function map($method, $route, $target, $name = null) { - + $route = $this->basePath . $route; $this->routes[] = array($method, $route, $target, $name); - + if($name) { - if(isset($this->namedRoutes[$name])) { - throw new \Exception("Can not redeclare route '{$name}'"); + if(isset($this->namedRoutes[$name])) { + throw new \Exception("Can not redeclare route '{$name}'"); } else { $this->namedRoutes[$name] = $route; } - + } return; @@ -61,7 +61,7 @@ class AltoRouter { $url = $route; if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) { - + foreach($matches as $match) { list($block, $pre, $type, $param, $optional) = $match; @@ -75,7 +75,7 @@ class AltoRouter { $url = str_replace($block, '', $url); } } - + } @@ -222,4 +222,4 @@ class AltoRouter { } return "`^$route$`"; } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d98ed55 --- /dev/null +++ b/composer.json @@ -0,0 +1,23 @@ +{ + "name": "niahoo/altorouter", + "description": "A lightning fast router for PHP", + "keywords": ["router", "routing", "lightweight"], + "homepage": "https://github.com/niahoo/AltoRouter", + "authors": [ + { + "name": "Danny van Kooten", + "email": "dannyvankooten@gmail.com", + "homepage": "http://dannyvankooten.com/" + }, + { + "name": "niahoo", + "email": "dev@ooha.in" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "files": ["AltoRouter.php"] + } +} diff --git a/index.php b/index.php index 885649f..e8c6ab4 100644 --- a/index.php +++ b/index.php @@ -24,4 +24,4 @@ $match = $router->match();