How to access environment variables in symfony 5 without autowire

Say I have a database CRUD class that needs to configure Mysql. I’ve figured out how to set the environmental variables, but I have found nothing in the documentation about how to access them inside of services other than some spectacularly complex pattern of creating a bundle and autowiring etc.

I don’t want to have to have this class dependency injected all over where it is needed. I have tried using getenv but it returns false even when the variables are set for some odd reason.

Any ideas?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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