Set application root absolute path in magento

Posted by Damodar Bashyal on April 19, 2013

 

If you want to change the path of magento core application folder, then you can set it as:

Mage::setRoot('/path/to/your/app');

If you look into app/Mage.php you will find that function.

    /**
     * Set application root absolute path
     *
     * @param string $appRoot
     * @throws Mage_Core_Exception
     */
    public static function setRoot($appRoot = '')
    {
        if (self::$_appRoot) {
            return ;
        }
 
        if ('' === $appRoot) {
            // automagically find application root by dirname of Mage.php
            $appRoot = dirname(__FILE__);
        }
 
        $appRoot = realpath($appRoot);
 
        if (is_dir($appRoot) and is_readable($appRoot)) {
            self::$_appRoot = $appRoot;
        } else {
            self::throwException($appRoot . ' is not a directory or not readable by this user');
        }
    }
 
not published on website


QR Code: Set application root absolute path in magento