From fe4d390f0c1eeca403051289abb1a4932cf252f0 Mon Sep 17 00:00:00 2001 From: niahoo Date: Wed, 6 Mar 2013 11:09:46 +0100 Subject: [PATCH 1/2] added composer.json and newlines in end of files --- .htaccess | 2 +- AltoRouter.php | 16 ++++++++-------- composer.json | 19 +++++++++++++++++++ index.php | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 composer.json 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..39808e8 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "altorouter/altorouter", + "description": "A lightning fast router for PHP", + "keywords": ["router", "routing", "lightweight"], + "homepage": "https://github.com/dannyvankooten/AltoRouter", + "authors": [ + { + "name": "Danny van Kooten", + "email": "dannyvankooten@gmail.com", + "homepage": "http://dannyvankooten.com/" + } + ], + "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();

Try these requests:

GET generate('home'); ?>

GET generate('users_show', array('id' => 5)); ?>

-

\ No newline at end of file +

From bf439f0c9421677ae577ba99c4427f8cf2f78933 Mon Sep 17 00:00:00 2001 From: niahoo Date: Sun, 17 Mar 2013 20:34:37 +0100 Subject: [PATCH 2/2] change composer package name to niahoo/altorouter --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 39808e8..d98ed55 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,17 @@ { - "name": "altorouter/altorouter", + "name": "niahoo/altorouter", "description": "A lightning fast router for PHP", "keywords": ["router", "routing", "lightweight"], - "homepage": "https://github.com/dannyvankooten/AltoRouter", + "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": {