Search code examples
phpapachesymfonyroutessymfony-2.3

Symfony can't find any routes


Me and the team have been working on a relatively large Symfony project. We've been working locally using XAMPP on all windows PC's, and have barely encountered any errors. Recently I have taken on the task of testing the application on linux (CrunchBang linux) and I've encountered some pretty serious errors. I've been looking all StackOverflow, and tried pretty much all I could find.

App.php (localhost/) returns a blank screen. App_dev.php (localhost/app_dev.php) gives me the following 2 errors:

1/2 ResourceNotFoundException:

in /home/tim/web/grip.dev/app/cache/dev/appDevUrlMatcher.php line 136
at appDevUrlMatcher->match('/') in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1207
at Router->match('/') in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1872
at RouterListener->onKernelRequest(object(GetResponseEvent))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent)) in /home/tim/web/grip.dev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 450
at TraceableEventDispatcher->Symfony\Component\HttpKernel\Debug\{closure}(object(GetResponseEvent))
at call_user_func(object(Closure), object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1667
at EventDispatcher->doDispatch(array(object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure)), 'kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1600
at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1764
at ContainerAwareEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 139
at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2833
at HttpKernel->handleRaw(object(Request), '1') in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2818
at HttpKernel->handle(object(Request), '1', true) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2947
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2249
at Kernel->handle(object(Request)) in /home/tim/web/grip.dev/web/app_dev.php line 28

2/2 NotFoundHttpException: No route found for "GET /"

in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1883
at RouterListener->onKernelRequest(object(GetResponseEvent))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent)) in /home/tim/web/grip.dev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 450
at TraceableEventDispatcher->Symfony\Component\HttpKernel\Debug\{closure}(object(GetResponseEvent))
at call_user_func(object(Closure), object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1667
at EventDispatcher->doDispatch(array(object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure)), 'kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1600
at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/cache/dev/classes.php line 1764
at ContainerAwareEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 139
at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2833
at HttpKernel->handleRaw(object(Request), '1') in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2818
at HttpKernel->handle(object(Request), '1', true) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2947
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /home/tim/web/grip.dev/app/bootstrap.php.cache line 2249
at Kernel->handle(object(Request)) in /home/tim/web/grip.dev/web/app_dev.php line 28

If I call php app/console router:debug it returns the following:

[router] Current routes
Name                     Method Scheme Host Path
_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_purge          ANY    ANY    ANY  /_profiler/purge
_profiler_info           ANY    ANY    ANY  /_profiler/info/{about}
_profiler_import         ANY    ANY    ANY  /_profiler/import
_profiler_export         ANY    ANY    ANY  /_profiler/export/{token}.txt
_profiler_phpinfo        ANY    ANY    ANY  /_profiler/phpinfo
_profiler_search_results ANY    ANY    ANY  /_profiler/{token}/search/results
_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
_configurator_home       ANY    ANY    ANY  /_configurator/
_configurator_step       ANY    ANY    ANY  /_configurator/step/{index}
_configurator_final      ANY    ANY    ANY  /_configurator/final

All routing works on Windows with XAMPP.

Somehow I think it's related to my apache2 configuration. I have set up mod rewrite and the web/.htaccess uses RewriteEngine On. My vHosts are also configured to 'AllowOverride All'. I don't have a lot of experience with manually configuring apache2, apart from the things I found.

My PHP version is 5.4.4-14+deb7u5.

EDIT: We redirect our routing to a custom routing file: (app/config/config.yml)

framework:
    router:
        resource: "@CoreBundle/Resources/config/routing.php"

Here is our routing.php:

<?php

use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$collection = new RouteCollection();

//Routes for other bundles go here

/*
 * Route format for other bundles.
 * -------------------------------
 * $<bundlename>Routing = $loader->import("@<bundlenamespace>/Resources/config/routing.php");
 * $<bundlename>Routing->addPrefix('<Insert bundle prefix>');
 * $collection->addCollection($<bundlename>Routing);
 * -------------------------------
 * Add a whiteline in between each bundle route.
 */

$gripRouting = $loader->import("@GripBundle/Resources/config/routing.php");
$gripRouting->addPrefix('/grip');
$collection->addCollection($gripRouting);

$ddsRouting = $loader->import("@DDSBundle/Resources/config/routing.php");
$ddsRouting->addPrefix('/dds');
$collection->addCollection($ddsRouting);

//Routes for the core bundle go here
$collection->add('login', new Route('/login', array(
    '_controller' => 'CoreBundle:Login:login',
)));

$collection->add('login_check', new Route('/login_check', array()));

$collection->add('core_logout', new Route('/logout', array()));

$collection->add('products', new Route('/products', array(
    "_controller" => "CoreBundle:Default:products",
)));

$collection->add('about', new Route('/about', array(
    "_controller" => "CoreBundle:Default:about",
)));

$collection->add('contact', new Route('/contact', array(
    "_controller" => "CoreBundle:Default:contact",
)));

$collection->add('core_noclient', new Route("/error", array(
    "_controller" => "CoreBundle:Default:noClient",
)));

// Vendor bundles
$securityCollection = $loader->import("@FOSUserBundle/Resources/config/routing/security.xml");
$collection->addCollection($securityCollection);

$profileCollection = $loader->import("@FOSUserBundle/Resources/config/routing/profile.xml");
$profileCollection->addPrefix("/profile");
$collection->addCollection($profileCollection);

$registrationCollection = $loader->import("@FOSUserBundle/Resources/config/routing/registration.xml");
$registrationCollection->addPrefix("/register");
$collection->addCollection($registrationCollection);

$resettingCollection = $loader->import("@FOSUserBundle/Resources/config/routing/resetting.xml");
$resettingCollection->addPrefix("/resetting");
$collection->addCollection($resettingCollection);

$changePasswordCollection = $loader->import("@FOSUserBundle/Resources/config/routing/change_password.xml");
$changePasswordCollection->addPrefix("/profile");
$collection->addCollection($changePasswordCollection);

$gripRouting = $loader->import("@SonataAdminBundle/Resources/config/routing/sonata_admin.xml");
$gripRouting->addPrefix('/admin');
$collection->addCollection($gripRouting);

$gripRouting = $loader->import(".", "sonata_admin");
$gripRouting->addPrefix('/admin');
$collection->addCollection($gripRouting);

$gripRouting = $loader->import("@SonataUserBundle/Resources/config/routing/admin_security.xml");
$gripRouting->addPrefix('/admin');
$collection->addCollection($gripRouting);

$collection->add('core_home', new Route('/', array(
    '_controller' => 'CoreBundle:Default:index',
)));

return $collection;

Solution

  • I fixed it. I'm still in the blue about what really happened but it seemed to be caused by both PHP-APC and my cache. I cleared the cache, removed the content of the folders and set up the permissions again using setfacl. I also updated using composer, possibly refreshing my parameters.yml to the proper settings.

    I hope I help someone with these small 'pointers'.