How to fix Warning: is_readable(): open_basedir restriction in effect in Zend Framework => 1.10

If you are getting load of this error after upgrading to Zend framework 1.10 and greater, you can fix it by changing Zend/Loader.php file

Change method isReadable() to following
Also make sure anything in your include path should be in your basedir option too.
Waring!!! use the code at your own risk as I have not done extensive tests.


    /**
     * Returns TRUE if the $filename is readable, or FALSE otherwise.
     * This function uses the PHP include_path, where PHP's is_readable()
     * does not.
     *
     * Note from ZF-2900:
     * If you use custom error handler, please check whether return value
     *  from error_reporting() is zero or not.
     * At mark of fopen() can not suppress warning if the handler is used.
     *
     * @param string   $filename
     * @return boolean
     */
    public static function isReadable($filename)
    {
        if (is_readable($filename)) {
            // Return early if the filename is readable without needing the 
            // include_path
            return true;
        }

        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
            && preg_match('/^[a-z]:/i', $filename)
        ) {
            // If on windows, and path provided is clearly an absolute path, 
            // return false immediately
            return false;
        }

        if(strpos($filename, '/')==0) return false; //if absolute path skip

        foreach (self::explodeIncludePath() as $path) {
            if ($path == '.') {
                if (is_readable($filename)) {
                    return true;
                }
                continue;
            }
            $file = $path . '/' . $filename;
            if (is_readable(realpath($file))) {
                return true;
            }
        }
        return false;
    }

6 thoughts on “How to fix Warning: is_readable(): open_basedir restriction in effect in Zend Framework => 1.10”

  1. Thank u very much ! I get this error, and after a while, i found your web with your perfect solution. It works fine with my problem.

    1. Thank you very much ! Really Thanks.
      I had a big headache coz’ of this. Your post give me
      a good solution. It works well. Thank you.

  2. problem with open_basedir (php 5.3+)

    set_include_path(
    APPLICATION_PATH.’/../library’.PATH_SEPARATOR.
    APPLICATION_PATH.’/../library/Zend’
    );

    + ini_set(‘open_basedir’, ini_get(‘open_basedir’) . PATH_SEPARATOR . ‘/../absolute path/’);

  3. Thank you very much! Great job. I have wasted two days searching on the net for this solution. Being just a beginner in Zend Framework, I thought that the problem was caused by the paths setted in index.php and I’ve tried as many combinations as I could think of, searching for the right one. I was just about to get crazy when I found this page. Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>