How to Get Root Directory Path in Magento 2

Are you a Magento developer working on building extensions?

If yes, then you will have to get root directory path in Magento 2.

You will need access to data stored in the root folder which can be obtained using the directory path.

Hence, implement the below solution to get a directory path in Magento 2.

Method to Get Root Directory Path in Magento 2:

or
Get other directory paths like:
 

That’s it.

Any doubts about the solution can be mentioned in the Comments section below. I’d be glad to help you out.

Do share the solution with the Magento Community via social media.

Thank you.

4.5
(based on 8 Reviews)
How to Get Root Directory Path in Magento 2

Ronak Bhatti

Ronak is a Magento Developer at Meetanshi. He loves playing cricket. Apart from the work, he is an enthusiastic person who loves learning new skills.

Leave a Reply

Your email address will not be published.