12

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?

3 Answers 3

31

You can use

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

to rebuild the routing information without clearing all the caches.

7
  • Handy. Only takes 3.5s, a big improvement, many thanks. Shame there's not a drush command for this. Commented Jun 17, 2015 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. Commented Jun 17, 2015 at 9:49
  • @Berdir This looks relevant? but it doesn't do the same as this answer says: github.com/drush-ops/drush/commit/… Commented Jun 17, 2015 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. Commented Jun 17, 2015 at 18:28
  • Good idea berdir! Commented Jun 18, 2015 at 5:48
9

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 
9
drush cc router 

when using drush 9 do the trick now :-)

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.