10

Having worked with Drupal 7 since its launch, I'm learning Drupal 8. At the moment I'm finding that whenever I change anything I have to do drush cache-rebuild to get things working again.

On my VPS this takes 15 seconds (and then the next page load also is slow). I have a feeling this may be a sledge hammer to crack a nut situation.

Is there a more efficient way to get Drupal to recompile the (changed) routes from {module}.routing.yml files?

19

You can use

drush ev '\Drupal::service("router.builder")->rebuild();'

to rebuild the routing information without clearing all the caches.

  • Handy. Only takes 3.5s, a big improvement, many thanks. Shame there's not a drush command for this. – artfulrobot Jun 17 '15 at 8:28
  • Pretty sure that a PR to add a drush cc something would be a accepted, it's a common use case. Or maybe as part of "drush cc menu", which already exists but likely doesn't do much in D8. – Berdir Jun 17 '15 at 9:49
  • @Berdir This looks relevant? but it doesn't do the same as this answer says: github.com/drush-ops/drush/commit/… – artfulrobot Jun 17 '15 at 10:15
  • Related, but that just invalidates the menu links, so it's about links.menu.yml. Seems like it should also cover the routes, local tasks and local actions. – Berdir Jun 17 '15 at 18:28
  • Good idea berdir! – Daniel Wehner Jun 18 '15 at 5:48
8

An alternative to drush is drupal console, which you can then use as:

drupal router:rebuild

Which is a little less typing than the drush ev answer (and a tinsy bit faster, too).

To install drupal console

curl -LSs http://drupalconsole.com/installer | php
mv console.phar /path/to/a/suitable/bin/drupal
2
drush cc router    

when using drush 9 do the trick now :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.