How to process %kernel.project_dir% from a .env variable?

I added this to my .env:


Of course, when I try to retrieve the value of $_ENV['PHOTOS_DIR'], I get the raw string %kernel.project_dir%/var/photos.

But how can I get the value processed by the Symfony config processor, e.g. /my/project/var/photos?

I’m aware that it is simply possible to add this in services.yaml:

    photos_dir: '%kernel.project_dir%/var/photos'

But I would like to keep important config data in the .env file.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *