The Drupal Console & Route Cache

Keep on Learning!

If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.

Start your All-Access Pass
Buy just this tutorial for $12.00

The Drupal Console!

Google for a new utility called "Drupal Console". This is a fantastic console script that helps you debug, clear cache and generate code. If you love it, you should say thank you to Jesus Olivas and others for their work! It's a bit like Drush, but different, but kind of the same... I don't know. They seem to be co-existing and don't do the exact same things.

To download it, copy the curl statement and run that in your terminal. Next, move it into a global bin directory so that you can simply type drupal from anywhere in the terminal:

curl -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal


If you're on windows, use the readfile line and don't worry about moving the file into a bin/ directory. Instead, you can type php drupal.phar to run the drupal.phar file that is downloaded.

Hello Drupal Console! Now try drupal list:

drupal list

This shows a huge list of all of the commands you can run. There is a lot of really good stuff in here - we'll cover some of these in this tutorial.

Clearing the Routing Cache

One of those commands is router:rebuild. Run that to clear the routing cache:

drupal router:rebuild

Ok, go back, refresh and congratulations!!! Seriously: you've just created your first custom page in Drupal 8. By the way, creating a page in the Symfony framework looks almost exactly the same. You're mastering two tools at once! You deserve a vacation.

Notice this page is literally only the text "ROOOOAR". It doesn't have any theming or templates applied to it. We will tap into the theme system later, but this is really interesting: if you want to return a Response all by yourself, you can do that and Drupal won't mess with it. Hey, this could even be a JSON response for an API. Drupal is a CMS, but it's also a modern, custom-development framework.

Leave a comment!

  • 2020-07-03 MonkeyBrain

    Running this on Drupal 9, few issues.
    Mainly Drupal Console is not currently compatible with Drupal 9. See
    ("Drupal Console is not yet compatible with Symfony 4, but Drupal 9 requires Symfony 4.")

    So you can use Drush instead.
    composer require drush/drush
    After downloading you have to run Drush as vendor/drush/drush/drush (unless you get into Drush Launcher etc).

    To clear all caches use vendor/drush/drush/drush cr

    Or to just rebuild the routing table (as in the tutorial) you can run vendor/drush/drush/drush ev '\Drupal::service("router.builder")->rebuild();'

  • 2019-09-13 weaverryan

    Hey Vyacheslav Demyanov !

    Good question. So, they "router:rebuild" is basically a way to *only* rebuild the routing cache... without rebuilding *all* your cache. And so, you should be able to rebuild the router cache by rebuilding *all* the caches. So, I'm actually surprised that the "Clear all caches" button isn't working... as that should clear all caches (including the router cache). Most commonly, this type of thing is handled via drush at deploy time - e.g. drush cache-rebuild (which will clear all the caches, including routing cache).

    Do you use Drush at deploy? Or, how do you clear the "rest of your cache" on deploy - with the "Clear all caches" button?


  • 2019-09-13 Vyacheslav Demyanov

    Hi, thank you for tutorial. I have a question.
    Every time we change the route we have to reset router cache and run "drupal router: rebuild". But what to do when we put our module on the production site and there is no way to run drupal router: rebuild. What to do in such cases? I'm faced a problem that until I update the router cache, I can’t see the settings for my module on the configuration page. Clear all caches buttom from "admin/config/development/performance" doesn't help.

  • 2017-09-18 Victor Bocharsky

    Hey Nina,

    Check out this instruction for Windows users: https://hechoendrupal.gitbo...


  • 2017-09-16 Nina

    I use windows. How can I install drupal console?

  • 2016-09-16 weaverryan

    Yo Bert!

    Yea, you're totally right! I just updated the code here:

    Thanks for pointing that out!

  • 2016-09-16 Bert Heyman

    Is it possible that this
    curl -L -o drupal.phar
    mv console.phar /usr/local/bin/drupal
    should be this?
    curl -L -o drupal.phar
    mv drupal.phar /usr/local/bin/drupal

  • 2016-03-03 crevillo

    you are very welcome. thanks for this courses. really like them.

  • 2016-03-03 weaverryan

    Interesting! I just tried http and it works for me. I wonder if some curl versions don't handle the redirect correctly... I'll update the code at least to use https, which is of course better anyways :).

    Thanks for the input!

  • 2016-03-01 crevillo

    i have same problem too on ubuntu 15.10. what worked for me is execute

    curl -L -o drupal.phar

    Looks http is not working for

    Wops. I said nothing. http redirects to https. but still don't work me with curl http...

  • 2015-12-14 weaverryan

    Hi there!

    Hmm, i'm not sure about this. Either your system had problems downloading the phar file (so just try it again), or there is some subtle system configuration that is somehow blocking the use of PHAR files. I don't see any issues on the DrupalConsole project ( for this, and as far as I can tell, it just seems like the installer file you downloaded with the curl command is corrupt. You should definitely not be having problems on a Mac - that's the most common development environment.


  • 2015-12-10 WEB BY DOUG

    When I run "curl -LSs | php" on Mac OS X 10.11.2 (El Captian) I get this error:

    Warning: Phar::mapPhar(-): failed to open stream: No such file or directory in - on line 9

    Fatal error: Uncaught exception 'PharException' with message 'unable to open phar for reading "-"' in -:9
    Stack trace:
    #0 -(9): Phar::mapPhar('console.phar')
    #1 {main}
    thrown in - on line 9