adding multiple routing using a single path #1
Conversation
README.md
Outdated
@@ -51,7 +51,7 @@ use Trulyao\PhpRouter\Router as Router; | |||
require(__DIR__ . '/../vendor/autoload.php'); | |||
|
|||
# Create a new instance | |||
$router = new Router(__DIR__."/views", "examples"); | |||
$router = new Router(__DIR__."/src", "examples"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The src
folder is not where the view is at, this assumes they have autoloader mapped to /src too and the index.php is outside that, the initial version was written to match the examples
folder. Check it out for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
src/Router.php
Outdated
@@ -123,23 +124,39 @@ private function add_route($path, $cb, $method = "GET") | |||
} | |||
|
|||
# Create a GET route | |||
public function get($path, $cb) { | |||
public function get($path = null, $cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having null
as a route is not user-friendly or visually pleasing, perhaps you could change it to simply take empty strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes . You are right. I notice that after creating the pull request.. sorry my bad
src/index.php
Outdated
@@ -1,6 +1,6 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great you caught this 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂 that was the first issue I ran into
Oh it’s alright. Also could you for the addition to the readme, could you switch to double quotes instead just to make it consistent? On 1 Aug 2022, at 01:27, Aniezeofor Chibueze Michael ***@***.***> wrote:
@codad5 commented on this pull request.
In src/Router.php:
@@ -123,23 +124,39 @@ private function add_route($path, $cb, $method = "GET")
}
# Create a GET route
- public function get($path, $cb) {
+ public function get($path = null, $cb) {
Yes . You are right. I notice that after creating the pull request.. sorry my bad
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Had to give reference to the main route object in the sub route .. due to the |
.htaccess
Outdated
@@ -0,0 +1,9 @@ | |||
Options +FollowSymLinks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For dev testing using using the PHP server, this is not necessary and as I mentioned, it is all routed to /examples, you are redirecting all traffic here and it might try to look for /examples in /examples itself again.
Just like express.js router this is to add multiple routing methods for a single route path
just like
instead of