I have tried to get the Symfony 4 setup. I followed the tutorial listed here: https://symfony.com/doc/4.0/setup.html
However when I attempt to run the server I get : 
I haven't changed anything and composer appears to be grabbing all the necessary dependencies. I ran the PHP to check earlier and there was nothing critical missing:

I'm really stuck here as this code should be working (it is working for anyone else I know) and it is from a source who would have checked it.
Update: Result from console from running router debug:
-------------------------- -------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------------------------
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler_open_file ANY ANY ANY /_profiler/open
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
-------------------------- -------- -------- ------ -----------------------------------
Stack traces:
Symfony\Component\Routing\Exception\ResourceNotFoundException:
at var/cache/dev/srcDevDebugProjectContainerUrlMatcher.php:107
at srcDevDebugProjectContainerUrlMatcher->match('/')
(vendor/symfony/routing/Matcher/UrlMatcher.php:95)
at Symfony\Component\Routing\Matcher\UrlMatcher->matchRequest(object(Request))
(vendor/symfony/routing/Router.php:262)
at Symfony\Component\Routing\Router->matchRequest(object(Request))
(vendor/symfony/http-kernel/EventListener/RouterListener.php:114)
at Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/Debug/WrappedListener.php:104)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(EventDispatcher))
(vendor/symfony/event-dispatcher/EventDispatcher.php:212)
at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
(vendor/symfony/event-dispatcher/EventDispatcher.php:44)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor/symfony/http-kernel/HttpKernel.php:125)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:66)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:190)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:37)
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
No route found for "GET /" (from "http://localhost/my-project/")
at vendor/symfony/http-kernel/EventListener/RouterListener.php:144
at Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/Debug/WrappedListener.php:104)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(EventDispatcher))
(vendor/symfony/event-dispatcher/EventDispatcher.php:212)
at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
(vendor/symfony/event-dispatcher/EventDispatcher.php:44)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
(vendor/symfony/http-kernel/HttpKernel.php:125)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:66)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:190)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:37)
There have been several questions like this since the new Symfony Flex installation process was released. Not sure that I have seen a good answer yet to what is basically a quirk.
Assume you install the basic skeleton and web server and then check the routes:
composer create-project symfony/skeleton skeleton
cd skeleton
composer require server
bin/console debug:router
------ -------- -------- ------ ------
Name Method Scheme Host Path
------ -------- -------- ------ ------
So no routes are defined out of the box. You can confirm this by looking at config/routes.yaml or in the empty src/Controller directory.
So what would you expect if you start the server and navigate to / in your browser? No route found for / of course. Instead, surprisingly, you actually get what looks like a welcome page. Hmmm. Where does that come from? Nothing in the actual FrameWork bundle is generating it.
Instead you need to dig down into the http-kernel component and see what happens when you try to match a route when no routes are defined. Eventually you end up in:
namespace Symfony\Component\HttpKernel\EventListener;
class RouterListener implements EventSubscriberInterface
try {
// matching a request is more powerful than matching a URL path + context, so try that first
if ($this->matcher instanceof RequestMatcherInterface) {
$parameters = $this->matcher->matchRequest($request);
} catch (ResourceNotFoundException $e) {
if ($this->debug && $e instanceof NoConfigurationException) {
$event->setResponse($this->createWelcomeResponse());
Basically, if you try to match a route and the router is not configured (in other words no routes are defined) then the welcome page is presented. Exactly why the Symfony developers did this is perhaps a bit of a mystery. Just something that needs to be accepted.
Now install the profiler and check routes.
composer req profiler
bin/console debug:router
-------------------------- -------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------------------------
_twig_error_test ANY ANY ANY /_error/{code}.
{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
...
We have routes. Nothing app or framework specific but the routing system is now configured. And if we refresh the browser, the welcome page is mysteriously replaced by the rather ominous looking Route Not Found exception.
Same thing happens if you install other bundles that define routes such as the security bundle. And of course the symfony/website-skeleton defines a bunch of internel routes. But not GET /.
TLDR: The GET / route is not defined by default even though it might seem like it. You will need to add it yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With