Shopware: Caching on dev

Time to share the pain of today. We are running on ddev. Which is an awesome piece of technology, with an awesome person behind it: Randy Fay.

Something is weird

For a while I had a weird feeling, that something is odd. It was hard to debug some of our projects, but I didn’t find time to dig into Shopware to nail down what the problem is.

Time to debug

Last week a colleague had the same problem – but neither I nor he did know it. We wanted to debug something else, but couldn’t find the SQL query we built – which makes it hard to debug.

Backstory

We started a while ago to centralise our ddev configurations and built automation around it. Which is awesome, because every project which is migrated to this standard looks the same and works under the same rules.

One of the things we did is to decide, that all projects run with Redis. And to achieve this, we added a redis docker instance for caching we threw a default framework.yaml into config/packages and the ENV variables into .env(.local) which looked like this:

#ddev-generated
framework:
cache:
app: cache.adapter.redis
default_redis_provider: '%env(string:REDIS_URL)%'

If you are familiar with Symfony you might already spot the problem. If you are running in APP_ENV=dev the cache is off by default. Except you overwrite the default configuration, e.g. by throwing a file in config/packages 🙄. The consequence is for example, that a lot of API router which are used by most controller return cached results and especially don’t query the database, so we can’t debug the SQL queries.

Lesson learned

Be very careful with default configurations!

Leave a Reply

Discover more from Winkelwagen

Subscribe now to keep reading and get access to the full archive.

Continue reading