symfony / symfony-docs

The Symfony documentation
https://symfony.com/doc
Other
2.18k stars 5.12k forks source link

MicroKernelTrait error #13865

Closed Surfoo closed 4 years ago

Surfoo commented 4 years ago

Hello,

I followed the first example A Single-File Symfony Application, just here: https://symfony.com/doc/current/configuration/micro_kernel_trait.html

And it doesn't work, here the log from Symfony CLI:

[Web Server/PHP ] Jun 19 00:05:02 |DEBUG| PHP    127.0.0.1:50258 Accepted path="/usr/bin/php" php="7.4.6"
[Web Server/PHP ] Jun 19 00:05:02 |ERROR| PHP    Uncaught PHP Exception TypeError: "Argument 1 passed to Kernel::configureRoutes() must be an instance of Symfony\Bundle\FrameworkBundle\Routing\Loader\Configurator\RoutingConfigurator, instance of Symfony\Component\Routing\RouteCollectionBuilder given, called in [***]/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php on line 171" at [***]/index.php line 33 
[Web Server/PHP ] Jun 19 00:05:02 |DEBUG| PHP     
[Web Server/PHP ] Jun 19 00:05:02 |DEBUG| PHP    127.0.0.1:50258 Closing 
[Web Server/PHP ] Jun 19 00:05:02 |ERROR| SERVER GET  (500) /random/10 ip="::1"

Can you confirm this bug by reproducing it?

javiereguiluz commented 4 years ago

The error says: "you must pass a RoutingConfigurator object, but you passed RouteCollectionBuilder".

But the page you linked to only uses "RoutingConfigurator". We changed this in the page very recently, maybe you were using a previous page version?

Surfoo commented 4 years ago

No cache issue, I opened the page for the first time yesterday.

The last commit on the rst file is about 3 months ago : https://github.com/symfony/symfony-docs/blob/5.1/configuration/micro_kernel_trait.rst not very recent :thinking:

javiereguiluz commented 4 years ago

You are right. This was fixed in #13394 a few months ago.

I was confused by this other PR #13852 from four days ago, which was related to the "RoutingConfigurator" vs "RouteCollectionBuilder" mismatch.


In any case, in the page you linked: https://github.com/symfony/symfony-docs/blob/5.1/configuration/micro_kernel_trait.rst you can see this code:

protected function configureRoutes(RoutingConfigurator $routes)

So, Symfony Docs are using RoutingConfigurator but the error you showed says "hey, you must use RoutingConfigurator but you are using RouteCollectionBuilder". That's why I don't fully understand the problem.

Surfoo commented 4 years ago

Here the bug from the browser : microkernel

The issue is in MicroKernelTrait.php, right ?

javiereguiluz commented 4 years ago

Yes, your code looks right. I still can't understand why this error happens, so I'll ask to the @symfony/team-symfony-docs to see if they can spot the error. Thanks!

xabbuh commented 4 years ago

Does it help if you rename the method to configureRouting()?

Surfoo commented 4 years ago

No, this method doesn't exist anyway in MicroKernelTrait.

"Kernel" uses "Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".
xabbuh commented 4 years ago

And if you change the use statement to use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;?

Surfoo commented 4 years ago

OK, it almost works now.

I have a 404: 404

wouterj commented 4 years ago

Please note that this is not an official support channel. Obviously, there is something wrong in the docs so this doc issue is still valid. However, if you need direct help with issues you're facing, you can get quicker help in one of the support channels: https://symfony.com/support (e.g. Slack or StackOverflow).

Please also note that it has been weekend and this project is almost fully run by volunteers. Things can take a bit longer than paid services :)

Surfoo commented 4 years ago

You are right, I have been rude in my previous message (deleted now), sorry.