hi..
I've recently setup apache with an alias to my network drive, so when I type

localhost/work/

it will fetch the network address

//marge/share/www/

when I type

localhost/work/index.php

I get the following error:

Warning: Failed opening '//marge/share/www/index.php' for inclusion (include_path='.;c:\php4\pear') in Unknown on line 0

Is there a setting in PHP which I need to change for it to have access to my drive? or am I missing something??

(the index.php file has "hello" as the contents.. that's all!)

thanks for any help 🙂

    5 years later

    bump

    I'm dying to know the answer for this question, I've got exactly same problem.

    In my case, I tried to include files in UNC location (//VBOXSVR/app), tried to map location as network drive (you've got to run apache from command line for that one to work) and location was Z:/app. In both cases there was the same problem with include.
    Most interesting part is when I copied those files to C: and D: physical drives, it worked like a charm.

    Anyone knows the answer?

      Have you verified that the security permissions of the network share allow the account that the Apache service/executable is running under to access it?

        Yes I did, I started Apache from the account I was logged in (tried from command line and as a service). It had access to every file on mapped drive, everything worked as it should, except include() (I think that the set_include_path() function with include_path directed to network location is a problem here).

          Can you verify something for me? Create a .php file that looks like this:

          <?php
          
          echo 'You are: ' . `whoami`;

          and view it from your browser. What is the output?

            Output is:

            You are: mypc\mleczunio

            As I said, I'm starting Apache from user 'mleczunio'.

              Okay.. can you also post the exact code you're using as well as the full PHP error message(s) that gets generated?

                It's not easy because it's whole Zend Framework, I'll paste important parts:

                index.php :

                // (...) Hello, I'm Zend Framework gibberish (...)
                
                // Ensure library/ is on include_path
                set_include_path(
                    MAIN_PATH . '/library'
                    . PATH_SEPARATOR . MAIN_PATH . '/application'
                    . PATH_SEPARATOR . get_include_path()
                );
                
                // (...) Hello, I'm Zend Framework gibberish (...)
                

                And the part that causes the problem:
                library/Zend/View/PluginLoader.php (line 360):

                public function load($name, $throwExceptions = true)
                    {
                        $name = $this->_formatName($name);
                        if ($this->isLoaded($name)) {
                            return $this->getClassName($name);
                        }
                
                    if ($this->_useStaticRegistry) {
                        $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry];
                    } else {
                        $registry = $this->_prefixToPaths;
                    }
                
                    $registry  = array_reverse($registry, true);
                    $found     = false;
                    $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
                    $incFile   = self::getIncludeFileCache();
                    foreach ($registry as $prefix => $paths) {
                        $className = $prefix . $name;
                
                        if (class_exists($className, false)) {
                            $found = true;
                            break;
                        }
                
                        $paths     = array_reverse($paths, true);
                
                        foreach ($paths as $path) {
                            $loadFile = $path . $classFile;
                            if (Zend_Loader::isReadable($loadFile)) {
                                include_once $loadFile;
                                if (class_exists($className, false)) {
                                    if (null !== $incFile) {
                                        self::_appendIncFile($loadFile);
                                    }
                                    $found = true;
                                    break 2;
                                }
                            }
                        }
                    }
                
                    if (!$found) {
                        if (!$throwExceptions) {
                            return false;
                        }
                
                        $message = "Plugin by name '$name' was not found in the registry; used paths:";
                        foreach ($registry as $prefix => $paths) {
                            $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths);
                        }
                        require_once 'Zend/Loader/PluginLoader/Exception.php';
                        throw new Zend_Loader_PluginLoader_Exception($message);
                   }
                
                    if ($this->_useStaticRegistry) {
                        self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]     = $className;
                    } else {
                        $this->_loadedPlugins[$name]     = $className;
                    }
                    return $className;
                }
                

                Output is:

                Fatal error: Uncaught exception 'Zend_Exception' with message 'exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'Doctype' in Z:\WebCgiRole1\index.php on line 41

                What's most interesting, I just realized that if I'll execute very simple code that I've written by myself a while ago:

                <?php
                
                  set_include_path(realpath('./include_files').PATH_SEPARATOR.get_include_path());
                
                  include('subFolder/included_file.php');

                It works on mapped network drive o_O.

                But... Exact same Zend Project works perfectly on a regular drive, I can also mention that there are full read/write/execute permissions on every file and directory in the project on a network drive.

                  Ok, I've found exact line that causes the problem. It is not the problem with include() function, but with is_readable() function.

                  library/Zend/Loader.php (line 174):

                   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;
                      }
                  
                      foreach (self::explodeIncludePath() as $path) {
                          if ($path == '.') {
                              if (is_readable($filename)) {
                                  return true;
                              }
                              continue;
                          }
                          $file = $path . '/' . $filename;
                          echo $file.' ';
                          if (is_readable($file)) {
                              return true;
                          }
                      }
                      return false;
                  }

                  AND if I put this line:

                  die(is_readable('Z:\appgen_azure\WebCgiRole1/library/Zend/View/Helper/Doctype.php') ? 'readable' : 'not readable');

                  I get 'not readable'. But the file IS readable for sure.

                    Ok, sorry for triple-posting, I solved the problem and the solution is:

                    If you are using VirtualBox and you're sharing same issue, give up sharing folders through VirtualBox and share them with regular network.
                    It turns that VirtualBox sharing system caused all of these and the problem was is_readable() function that returned false() for some reason.

                    Thank you very much for help 🙂

                      Write a Reply...