-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new improved auto router #5889
Conversation
80721ed
to
f6e101d
Compare
This might be a wildly-inappropriate idea but... in addition to the method-naming convention ( We would need something like "if PHP version > 8", and I'm not even sure if you can handle attributes conditionally with valid syntax... but that's why it is wild. 😅 |
In my opinion or modeling, there are two routers.
Defined Route Router has RouteCollection. So if we agree with "if PHP version >= 8" and adding Attributes for routes, I could send another PR for it.
No problem. Attributes are just PHP comments. |
I think for sure in version 5 we should have a Router interface or abstract class with multiple different handlers. They could cascade or whatever to support different definitions at once. Let's see what Lonnie has to say on the other PR before you go doing a bunch more work on this one. |
6a39da0
to
39de15d
Compare
@samsonasik Do you know why?
https://github.com/codeigniter4/CodeIgniter4/runs/5984021110?check_suite_focus=true I ran it with
|
@kenjis I am not sure, probably it tries to load |
@samsonasik How to get $rectorConfig? |
I found docs for v0.12.20: |
--- a/rector.php
+++ b/rector.php
@@ -126,6 +126,10 @@ return static function (ContainerConfigurator $containerConfigurator): void {
// auto import fully qualified class names
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
+ $parameters->set(Option::AUTOLOAD_PATHS, [
+ __DIR__.'/app/Controllers/BaseController.php',
+ ]);
+
$services = $containerConfigurator->services();
$services->set(UnderscoreToCamelCaseVariableNameRector::class);
$services->set(SimplifyUselessVariableRector::class); But nothing changes.
|
@samsonasik I solved the problem. The controllers that test case use extended Thanks for the help. |
@kenjis RectorConfig is extended class of |
3de8b85
to
5fd2ddb
Compare
If everything looks Okay, I will add the documentation. |
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.
Looks good to me.
f4ca622
to
e7a4829
Compare
Added the user guide updates. Review, please. |
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.
Some comments. I like the direction this is heading and think it is very close. I haven't tested it myself in a real app yet but I would like to (or someone else to).
This is a fairly large change and will inevitably generate forum questions and issues so let's try to get the whole team to look at it. The new docs helped me understand it much better - very nice work on those.
Error: ] Could not process "tests/system/Router/AutoRouterImprovedTest.php" file, due to: "System error: "Class 'App\Controllers\BaseController' not found" Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 16
Remove unneeded if condition. Fix exception message.
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
Co-authored-by: MGatner <mgatner@icloud.com>
Co-authored-by: MGatner <mgatner@icloud.com>
Co-authored-by: MGatner <mgatner@icloud.com>
f495513
to
70f62aa
Compare
Why is the |
Because it is better to implement the interface, not extending the class. |
Needs to rebase after merging #5877Description
An optional new more secure auto router.
AutoRouterImproved
class andAutoRouterInterface
Config\Feature::$autoRoutesImproved
(false
by default)AutoRouterImproved
inRouter
if enabledAutoRouterImproved
changes:getIndex()
,postCreate()
.home
by default) and the Default Method (index
by default) must be omitted in the URI./
, but/home
and/home/index
are 404._remap()
method.Checklist: