Forgive me for my naivete but I'm modifying a custom extension and I see this variable:

$mediaPath = $fileSystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath();

I went through Magento\Framework\App\Filesystem\DirectoryList but can't find any mention of ::MEDIA. Can someone please clue me in? Thank you! I'm new to M2.

1 Answer 1


It's there - https://github.com/magento/magento2/blob/67ee5ff13590936a320bfa6126181a091cb0005a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php#L48 - you're looking for the class constant defined as const MEDIA = 'media';

Though the path most likely will not be the same as in the git, it's probably vendor/magento/framework/App/Filesystem/DirectoryList.php for you.

See also https://www.php.net/manual/en/language.oop5.constants.php


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.