I want to make something that in Drupal 7 can easily be done with hook_init, but this hook doesn't exists in Drupal 8.

I want to load an .env file and at the same time load the dotenv file from vendor.

I'm trying with EventSubscriber as it's plain here: https://www.drupal.org/node/2013014, but I'm not sure if this the good way.


I think that you actually already har answered your own question. EventSubscribers is the way we do it in Drupal 8, so it might be right what you are trying to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.