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

I added this to my .env:

PHOTOS_DIR=%kernel.project_dir%/var/photos

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?

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

parameters:
    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 *