With a Subscription, click any sentence in the script to jump to that part of the video!

Login Subscribe

I want to talk more about this key: markdown.parser.light:

service: markdown.parser.light

We got this from the documentation: it told us that there are five different valid values that we can put for the service key.

But, this is more than just a random config key that the bundle author dreamt up. Remember: all services live inside an object called the container. And each has an internal name, or id.

It's not really important, but it turns out that markdown.parser.light is the id of a service in the container! Yep, with this config, we're telling the bundle that when we ask for the Markdown parser - like we are in the controller - it should now pass us the service that has this id.

Go to your terminal and run:

./bin/console debug:autowiring

And scroll to the top. Check this out! The MarkdownInterface is now an alias to markdown.parser.light! Before the config change, this was markdown.parser.max. Yep, this literally means that when we use MarkdownInterface, Symfony will pass us a service whose id is markdown.parser.light.

Normally, you do not need to worry about all of this. I mean, if you just want to use this bundle and configure a few things, follow its docs, make some config tweaks, go on a space walk, and then keep going!

The Many other Services in the Container

But we're on a quest to really understand how things work! Here's the truth, this is not a full list of all of the services in the container. Nope, not even close. This time, run:

./bin/console debug:container --show-private

This is actually the full list of the many services in the container. The service id is on the left, and the class for that object is on the right. Don't worry about the --show-private flag: that just makes sure this lists everything.

But, in reality, most of these services are internal, boring objects that you'll never use. The most important services show up in debug:autowiring and are really easy to access.

But yea... you can also fetch and use any of these services, and sometimes you'll need to. I'll show you how a bit later.

But here are the two big takeaways:

  1. There are many services in the container and each has an id.
  2. The services you'll use 99% of the time show up in debug:autowiring and are easy to access.

Configuring the Cache Object

Let's play with one more object. Instead of dumping $markdown, dump the $cache object:

... lines 1 - 13
class ArticleController extends AbstractController
... lines 16 - 26
public function show($slug, MarkdownInterface $markdown, AdapterInterface $cache)
... lines 29 - 53
... lines 55 - 67
... lines 69 - 80

Find your page and refresh! Interesting: it's something called a TraceableAdapter, and, inside, a FilesystemAdapter!

So I guess our cache is being saved to the filesystem... and we can even see where in var/cache/dev/pools.

So... how can we configure the cache service? Of course, the easiest answer is just to Google its docs. But, we don't even need to do that! The cache service is provided by the FrameworkBundle, which is the one bundle that came automatically with our app.

Debugging your Current Config


In a recent change to the recipe, the cache config now lives in its own file config/packages/cache.yaml

Open framework.yaml and scroll down:

... lines 2 - 16
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The app cache caches to the filesystem by default.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

Hey! This file even comes with documentation about how to configure the cache! Of course, to get an even bigger example, we can run:

./bin/console config:dump framework

Here's the cache section, with some docs about the different keys. Now, try a slightly different command:

./bin/console debug:config framework

Instead of dumping example config, this is our current config! Under cache, there are 6 configured keys. But, you won't see all of these in framework.yaml: these are the bundle's default values. And yea! You can see that this app key is set to cache.adapter.filesystem.

Changing to an APCu Cache

The docs in framework.yaml tell us that, yep, if we want to change the cache system, app is the key we want. Let's uncomment the last one to set app to use APCu: an in-memory cache that's not as awesome as Redis, but easier to install:

... lines 2 - 16
... lines 18 - 28
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
app: cache.adapter.apcu

And just like with markdown, cache.adapter.apcu is a service that already exists in the container.

Ok, go back and refresh! Yes! The cache is now using an APCuAdapter internally!


Fun fact! Running ./bin/console cache:clear clears Symfony's internal cache that helps your app run. But, it purposely does not clear anything that you store in cache. If you want to clear that, run ./bin/console cache:pool:clear

Bundle Config: the Good & Bad

So the great thing about configuring bundles is that you can make powerful changes with very simple config tweaks. You can also dump your config and Symfony will give you a great error if you have any typos.

The downside about configuring bundles is that... you really need to rely on the debug tools and documentation. I mean, there's no way we could sit here long enough and eventually figure out that the cache system is configured under framework, cache, app: the config structure is totally invented by the bundle.

Let's go back to our controller and remove that dump:

... lines 1 - 13
class ArticleController extends AbstractController
... lines 16 - 26
public function show($slug, MarkdownInterface $markdown, AdapterInterface $cache)
... lines 29 - 53
... lines 55 - 67
... lines 69 - 80

Make sure everything still works. Perfect! If you get an error, make sure to install the APCu PHP extension.

Next, let's explore Symfony environments and totally demystify the purpose of each file in config/.

Leave a comment!

  • 2019-04-08 Victor Bocharsky

    Hey Abelardo,

    Thank you for sharing this with others!


  • 2019-04-07 Abelardo León González

    Hi everyone,
    In order to install APCu inside Linux, you must run:

    $ sudo apt-get install php-apcu

    Best regards

  • 2019-01-30 Dirk J. Faber

    I thought this was the case, but wasn't sure. Thanks Diego!

  • 2019-01-29 Diego Aguiar

    Hey Dirk J. Faber

    On production you have to clear the cache after doing almost any change, by running bin/console cache:clear
    but if you are on "dev" environment you don't have to manually run that command, Symfony is very smart at detecting when to clear the cache but sometimes you have to manually clear the "var/cache" folder, it's a rare situation but sometimes you have to do it.


  • 2019-01-29 Dirk J. Faber

    Perhaps a silly question, but I don't fully understand when you want to clear Symfony's internal cache. Should you do this just once when you deploy your application? Or should you do it (also) every time you make changes to your application's code (a change to a controller or a twig-file for example)?

  • 2019-01-22 Victor Bocharsky

    Hey Mathieu,

    Sure, since you uncomment APCu cache adapter - you should have it installed and enabled so you can use it in your application. And that's great that you got a clear error message for it.


  • 2019-01-18 Mathieu Jourdan

    Does it mean that you only need to uncomment the "app: cache.adapter.apcu" line in cache.yaml ?
    ... cause, by doing all the previous setup, i got a CacheException alert telling me that APCu in not enabled

  • 2019-01-03 weaverryan

    Hey Camille Seuvin!

    You're right! For clarity, in new projects, the cache config now lives in config/packages/cache.yaml. We'll add a note to the tutorial to make sure other people don't get confused!


  • 2019-01-03 Camille Seuvin

    For information : Cache config is in the cache.yaml file (and no longer in the framework.yaml file).

  • 2018-10-19 Saar Verberght

    You're the best <3

  • 2018-10-18 Diego Aguiar

    Hey Saar Verberght

    You should be able to enable APCu even for the Symfony's built-in web server but you have to install & enable it first on your computer. Probably this guide will help you:


  • 2018-10-18 Saar Verberght

    Hi guys, I have read all the comments but I can't seem to figure out how to enable the APCu when using the built in server of Symfony? Is this the moment I stop using the built in server and configure my own apache and php?

  • 2018-09-28 Diego Aguiar

    Hey Abelardo León González

    Thanks for the info man!

  • 2018-09-28 Abelardo León González

    Hi everyone,

    If apcu is not installed onto your system...


  • 2018-08-07 Mike

    You are brilliant! Thanks

  • 2018-08-06 weaverryan

    Hey Mike!

    Ah, VERY good question & point! First, if you did install the YAML PECL extension, it wouldn't make any difference: internally, Symfony always uses its own parser (it isn't written to fallback to the PECL version if it's available). But, more importantly, YAML is ONLY parsed when the container is being built. And this happens only in 2 different scenarios:

    1) During development, the container is rebuilt (and YAML is parsed) when refreshing after you've made some changes to your configuration files. So, it's not parsed on every request - only when needed.

    2) On production, the container is rebuilt only ONE time, during your deploy phase, when you run the bin/console cache:warmup command. Then, your YAML files are NEVER parsed again (you could even delete them!).

    So, the YAML parsing adds limited overhead during development and zero overhead during production. And even in development, I think you'd find that it is very little of your processing time (I've never benchmarked this, but I DO know that the code that takes up most of the time is PHP code that's independent of the YAML parsing).

    tl;dr You can't install the PECL extension to speed things up... but you also don't need to even worry about it ;).


  • 2018-08-06 Victor Bocharsky

    Hey Mike,

    Good question. APCu and OPcache are different things, as also APCu and APC are different things as well, because APCu is a *user* cache. If we're talking about legacy projects that does not have OPcache, then installing APC will improve performance, but if your PHP version already have OPcache - you don't need neither APC nor APCu, OPcache is enought. However, APCu can be used for cache other things, but it require some configuration.

    Btw, this article may be interesting for you:


  • 2018-08-04 Mike

    Speaking about performance, do you recommend to install the PECL YAML PHP Extension? Ive heard that it can parse up to 5x faster .YAML files than symfony itself.

  • 2018-08-04 Mike

    Is APCu recommended for most projects (instead of choosing nothing)?
    I have read on the internet: "All PHP packages now come pre-built with Zend OPcache by default, but you can still install APCu Cache as a data store." so does symfony performance improve with APCu instead of the default Zend OPcache?

  • 2018-07-19 Ante Domjanović

    i had also problem with installation (x64 version), but got worked with x86 version, check this link

  • 2018-07-13 Victor Bocharsky

    Hey Luis,

    Yes, agree, that would be cool, but it would be harder to maintain this code for us. And to be honest, Docker deserves a separate topic and not all our users may know and use this technology.


  • 2018-07-12 Luis Mas

    It would be nice to have a docker-compose installation in order to don't have to install APCu locally or struggle with its installation.

  • 2018-05-31 Victor Bocharsky

    Hey Daniel,

    Great! And thanks for sharing it with other Windows users!


  • 2018-05-30 Daniel

    I've found the answer here:

  • 2018-05-30 Daniel


    I'm struggling to install APCu PHP extension on Windows. How should it be done?

  • 2018-03-05 Victor Bocharsky

    Hey Chris,

    Thanks for sharing it! Anyway, after successful installation of new PHP extensions just do not forget to restart your web server. And btw, you also need to restart PHP-FPM if you use a real web server like Nginx or Apache along with PHP-FPM.


  • 2018-03-04 Chris R

    For those on Ubuntu 16.04 (or probably other Debian flavors) and using PHP 7.2, I ran the console command:

    sudo apt-get install php7.2-opcache php-apcu

    I then had to restart my server to get it to kick in:

    ./bin/console server:stop
    ./bin/console server:run
  • 2018-02-02 Diego Aguiar

    Oh, well, I more a linux/windows user, but I just found a post that may guide you in the right direction. Open this link: and scroll down to the section "Install OPcache and APCu"

    I hope it helps you. Cheers!

  • 2018-02-02 Jérôme 

    Hi Diego Aguiar

    Unfortunately, I didn't even manage to install APCu. I'm on a Macbook Air.

  • 2018-02-02 Victor Bocharsky

    Hey @rafix,

    To configure app.cache to use Redis you need to tweak the config to:

    app: cache.adapter.redis
    default_redis_provider: "redis://localhost"

    Here's some docs about RedisAdaper:

    > Can I pass a snc_redis config as parameter?
    Unfortunately no, as far as I see from its configuration. You can check it with "bin/console config:dump framework", looks for the "cache" key.

    FYI, here's related issue:


  • 2018-02-02 Diego Aguiar

    Hey Jérôme 

    If you managed to install APCu, maybe you just need to enable it, you have to add "" to your php.ini file (if you are on Windows I believe it should be "extension=apcu.dll", after that, restart your web server and everything should be ok.


  • 2018-02-01 Jérôme 


    I tried to code along but got stuck when I activated APCu in framework.yaml. When I refreshed the page, I got a CacheException and the following message: "APCu is not enabled". Of course, I watched the video in its entirety and know that I have to download the APCu PHP extension but after looking for a solution to do so, the only resource I found was this website: It concerns Wordpress, so I was wondering it this method is a good way to install APCu within the scope of this course, or do you suggest me another way?


  • 2018-01-31 rafix

    Hello Ryan, any reference to configure the app.cache using a redis cluster? Can I pass a snc_redis config as parameter?