multisite-bundle
multisite-bundle copied to clipboard
Avoid the generated route in the cache
I try you bundle in my sanbox. But I have this error, with app_dev.php
:
No route found for "GET /"
Or I my controller I have:
namespace Sandbox\PageBundle\Controller
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Alex\MultisiteBundle\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
class DefaultController extends Controller
{
/**
* @Route("/")
* @Method({"GET"})
* @Template()
*/
public function homepageAction()
{
die(var_dump($this->get('site_context')->getCurrentLocale()));
return array();
}
}
In my routing.yml, I have this:
sandbox_page:
resource: "@SandBoxPageBundle/Controller/"
type: annotation
prefix: /
I think the route are generated in cache, because when I delete the cache directory I don't have error.
So I would like to know if it's possible to avoid removing the cover lorsuqe we add a new route, with app_dev.php
Why have you added a prefix to a whole Controller directory instead of
sandbox_page:
resource: "@SandBoxPageBundle/Controller"
type: annotation
Can you copy/paste what is reported from app/console router:debug
?
Yes of course. I added the prefix because it's added when I generated a bundle.
app/console router:debug
:
_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
sandbox_page_default_get GET ANY ANY /hello/{name}
sandbox_page_default_homepage GET ANY ANY /
sandbox_page_default_put GET ANY ANY /put
sandbox_page_menu_get GET ANY ANY /menu
fos_user_security_login ANY ANY ANY /login
fos_user_security_check POST ANY ANY /login_check
fos_user_security_logout ANY ANY ANY /logout
fos_user_profile_show GET ANY ANY /profile/
fos_user_profile_edit ANY ANY ANY /profile/edit
fos_user_registration_register ANY ANY ANY /register/
fos_user_registration_check_email GET ANY ANY /register/check-email
fos_user_registration_confirm GET ANY ANY /register/confirm/{token}
fos_user_registration_confirmed GET ANY ANY /register/confirmed
fos_user_resetting_request GET ANY ANY /resetting/request
fos_user_resetting_send_email POST ANY ANY /resetting/send-email
fos_user_resetting_check_email GET ANY ANY /resetting/check-email
fos_user_resetting_reset GET|POST ANY ANY /resetting/reset/{token}
fos_user_change_password GET|POST ANY ANY /profile/change-password
Have you any idea?
Thx
Your command states there is a / URL, that sound weird. Sure it's not a cache issue?
It's probably your domain that is not the same as in your config.
If you define:
alex_multisite:
brandings:
foo:
fr_FR: { host: test.localhost }
You must use http://test.localhost - if you still use http://localhost, router won't be able to match.
Take a look at generated code in app/cache/dev/appDevUrlMatcher.php
I'm experiencing the same issues. It seems that routes are created and visibles through debug:router in CLI, but not reachable on the site until the cache is cleared, even in dev (app_dev.php).
I was digging in the code up to this point (Router/Loader/AnnotatedRouteControllerLoader.php) :
// cache will refresh when file is modified $collection->addResource(new FileResource($class->getFileName()));
Is it possible to disable this caching mechanism in dev mode (Symfony 3.2) ?