-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Symfony 4: No route found for "GET /" just after installation #9178
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
Comments
I can reproduce this bug with the given steps. Now let's find the cause of it and fix it. Thanks! |
I've just debug the error. The problem is that this code in if ('' === $code) {
$code .= " if ('/' === \$pathinfo) {\n";
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
$code .= " }\n";
} In my case, the
Maybe @yceruto, who created that code, can help us solve this problem. Thanks! |
Sadly, the trick (upon installation) only works if there is no package that adds a route to the application, and that isn't the case for See recipe |
Just thinking out loud: could we detect somehow in the dumper if there's any route associated with the |
@yceruto this super quick and dirty code solves the problem: $homepageIsDefined = false;
foreach ($collection as $dumperRoute) {
if ('/' === $dumperRoute->getRoute()->getPath()) {
$homepageIsDefined = true;
break;
}
}
if (!$homepageIsDefined) {
$code .= " if ('/' === \$pathinfo) {\n";
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
$code .= " }\n";
} |
The same problem. |
@yceruto I've proposed a simpler solution in symfony/symfony#26041 Hopefully it will fix this issue. |
I'm closing this issue because we are working on it on the code repository, which is where this can be fixed. Thanks! |
… (javiereguiluz) This PR was squashed before being merged into the 3.4 branch (closes #26041). Discussion ---------- Display the Welcome Page when there is no homepage defined | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#9178 | License | MIT | Doc PR | - In 3.4 we added a trick to display the Welcome Page when the user browses `/` and there are no routes defined. However, when using the `website-skeleton` (which is what most newcomers use ... and they are the ones that mostly need the "Welcome Page") the premise about *"no routes are defined"* is never true and the Welcome Page is never shown (see symfony/symfony-docs#9178 for one of the multiple error reports we've received). So, I propose to make this change to always define the "Welcome Page" as the fallback: * If no routes are defined for `/`, the Welcome Page is displayed. * If there is a route defined for `/`, this code will never be executed because it's the last condition of the routing matcher. Commits ------- 5b0d934 Display the Welcome Page when there is no homepage defined
… (javiereguiluz) This PR was squashed before being merged into the 3.4 branch (closes #26041). Discussion ---------- Display the Welcome Page when there is no homepage defined | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#9178 | License | MIT | Doc PR | - In 3.4 we added a trick to display the Welcome Page when the user browses `/` and there are no routes defined. However, when using the `website-skeleton` (which is what most newcomers use ... and they are the ones that mostly need the "Welcome Page") the premise about *"no routes are defined"* is never true and the Welcome Page is never shown (see symfony/symfony-docs#9178 for one of the multiple error reports we've received). So, I propose to make this change to always define the "Welcome Page" as the fallback: * If no routes are defined for `/`, the Welcome Page is displayed. * If there is a route defined for `/`, this code will never be executed because it's the last condition of the routing matcher. Commits ------- 5b0d934 Display the Welcome Page when there is no homepage defined
… (javiereguiluz) This PR was squashed before being merged into the 3.4 branch (closes #26041). Discussion ---------- Display the Welcome Page when there is no homepage defined | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#9178 | License | MIT | Doc PR | - In 3.4 we added a trick to display the Welcome Page when the user browses `/` and there are no routes defined. However, when using the `website-skeleton` (which is what most newcomers use ... and they are the ones that mostly need the "Welcome Page") the premise about *"no routes are defined"* is never true and the Welcome Page is never shown (see symfony/symfony-docs#9178 for one of the multiple error reports we've received). So, I propose to make this change to always define the "Welcome Page" as the fallback: * If no routes are defined for `/`, the Welcome Page is displayed. * If there is a route defined for `/`, this code will never be executed because it's the last condition of the routing matcher. Commits ------- 5b0d9340d7 Display the Welcome Page when there is no homepage defined
I had the same issue. I fixed it by creating a controller and modifying the routes.yami file. This video shows the solution at around 11:30 https://www.youtube.com/watch?v=t5ZedKnWX9E |
I'm not sure to understand the downvotes on this comment, the fix was merged and will be out in the next release, so this documentation will be fine. |
same problem .. anything useful here ? |
@Schrodinger0 What do you mean with "same problem"? |
That's expected, a new application has no default route. But there should be a nice page nonetheless displaying some information. And you can then continue creating your first page as described at https://symfony.com/doc/current/page_creation.html. |
I'm starting out with Symfony 4 following this guide https://symfony.com/doc/current/setup.html, so I have executed one after the other these commands:
composer create-project symfony/website-skeleton my-project
cd my-project
composer require server --dev
php bin/console server:run
but when I browse to
http://localhost:8000
I get aNo route found for "GET /"
error.The text was updated successfully, but these errors were encountered: