Closed SteeveDroz closed 2 years ago
Thank you for taking time.
This is not a bug. It is the specification for security reason.
Can’t access controllers in Defined Routes. It completely separates controllers accessible via Auto Routes from those accessible via Defined Routes. https://codeigniter.com/user_guide/changelogs/v4.2.0.html#new-improved-auto-routing
Adding a defined route to a method should not change the behavior of the auto routing of the other methods of the same controller.
Why do you think so?
Create a third method called
test
(notgetTest
).Define a route in
app/Config/Routes.php
like this:$routes->add('/test', 'Helloworld::test');
Everythink still works.
If you add the route definition, http://localhost:8080/helloworld and http://localhost:8080/helloworld/comment will be 404.
Can’t access controllers in Defined Routes. It completely separates controllers accessible via Auto Routes from those accessible via Defined Routes. https://codeigniter.com/user_guide/changelogs/v4.2.0.html#new-improved-auto-routing
Oh, my bad, I missed that part.
Thanks for your answer! It's indeed not a bug.
@SteeveDroz No problem.
By adding the method Home::getTest, the command php spark routes gives the result:
This part is a bug. I will fix it. Thank you for reporting.
PHP Version
8.1
CodeIgniter4 Version
4.2.0
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
Nginx
Database
No response
What happened?
The example in the tutorial breaks if I add a defined route for a method in the same controller.
Steps to Reproduce
Following the tutorial on the official website, create a controller called
Helloworld
with the methodsgetIndex
andgetComment
.Create a third method called
test
(notgetTest
).Define a route in
app/Config/Routes.php
like this:Everythink still works.
Change the route to:
The URI
/test
works, but/helloworld
and/helloworld/comment
don't (404 Page Not Found).Expected Output
Adding a defined route to a method should not change the behavior of the auto routing of the other methods of the same controller.
Anything else?
By adding the method
Home::getTest
, the commandphp spark routes
gives the result: