It appears on Craft 3.1.8 that I can't set the CRAFT_TEMPLATE_PATH from .env without throwing a PHP notice error. This appears to be because the .env is loaded after the defines and I want to access the .ENV for my CRAFTENV_template path.

How can I set CRAFT_TEMPLATE_PATH from my .env without producing an error/warning?

1 Answer 1


If you add it after you load the dot env stuff in your public index.php file, it should work:

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
    (new Dotenv(CRAFT_BASE_PATH))->load();


  • I had assumed that my be a bad idea after the autoload but it was still throwing an error. But could be my stack issue. Will take another look
    – joomkit
    Feb 14, 2019 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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