mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-23 11:39:15 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0df469184c | |||
| 649ed28a91 | |||
| 5cb7086e96 | |||
| a2edc1504c | |||
| d31cda8e70 | |||
| 921f050a31 |
@@ -1,5 +1,5 @@
|
||||
# Simple PHP router
|
||||
Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.
|
||||
Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the Laravel router.
|
||||
|
||||
## Installation
|
||||
Add the latest version pf Simple PHP Router to your ```composer.json```
|
||||
@@ -33,7 +33,7 @@ Add the latest version pf Simple PHP Router to your ```composer.json```
|
||||
|
||||
- Global Constraints
|
||||
- Sub-Domain Routing
|
||||
- Required parameters
|
||||
- Optional parameters
|
||||
|
||||
## Initialising the router
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ class RouterBase {
|
||||
throw new \InvalidArgumentException('Invalid type for getParams. Must be array or null');
|
||||
}
|
||||
|
||||
if($controller === null && $parameters === null) {
|
||||
if($controller === null && $parameters === null && $this->loadedRoute !== null) {
|
||||
return $this->processUrl($this->loadedRoute, null, $getParams);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ class RouterBase {
|
||||
$method = $tmp[1];
|
||||
}
|
||||
|
||||
if($controller === $c) {
|
||||
if($controller === $c && $route !== null) {
|
||||
return $this->processUrl($route, $method, $parameters, $getParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class RouterRoute extends RouterEntry {
|
||||
// Check if url parameter count matches
|
||||
if(stripos($url, $routeMatch) === 0) {
|
||||
|
||||
$matches = (count(explode('/', rtrim($url, '/'))) == count(explode('/', rtrim($route, '/'))));
|
||||
$matches = true;
|
||||
|
||||
if($this->regexMatch) {
|
||||
$parameters = $this->parseParameters($url, true, $this->regexMatch);
|
||||
@@ -61,6 +61,8 @@ class RouterRoute extends RouterEntry {
|
||||
|
||||
} else {
|
||||
|
||||
$matches = (count(explode('/', rtrim($url, '/'))) == count(explode('/', rtrim($route, '/'))));
|
||||
|
||||
$url = explode('/', $url);
|
||||
$route = explode('/', rtrim($route, '/'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user