1

I'm writing a module that needs to grab the path of a file.

I know I can use {{ alias('@webroot') }} in the templates to get the root web folder. Is there a way I can do this in module/plugin land?

I've been looking for PHP constants or similar, and landed on $fullpath = CRAFT_BASE_PATH . '/web/' . $filename; which doesn't feel great.

Cheers!

6

Would it be an option for you to use

Craft::getAlias('@webroot');

Yii2 Aliases

0

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.