0

im trying to create a Zend Framework custom Provider and here:

    if($module == 'default'){
        $modelsPath = dirname(__FILE__) . '/../application/models';
        $filePath = realpath($modelsPath) . '/' . $name . '.php';
    } else
    if(!$module == ''){
        $modelsPath = dirname(__FILE__) . '/../application/' . $module . '/models';
        $filePath = realpath($modelsPath) . '/' . $name . '.php';
    } else {
        die('Please enter a module!');
    }

when i im trying to create a path to the file and when its default module everything is ok, but when for ex. module is other word no matter what the realpath returns false?! where is the error?

fre2ak
  • 329
  • 2
  • 8
  • 18

3 Answers3

2

try using the APPLICATION_PATH constant.

if($module == 'default'){
        $modelsPath = APPLICATION_PATH . '/models';
        $filePath = realpath($modelsPath) . '/' . $name . '.php';
    } else
    if(!$module == ''){
        $modelsPath = APPLICATION_PATH . '/' . $module . '/models';
        $filePath = realpath($modelsPath) . '/' . $name . '.php';
    } else {
        die('Please enter a module!');
    }
0

Taken out of the php manual:

realpath() returns FALSE on failure, e.g. if the file does not exist.

Note:

The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

So the problem most probably is with folder permission or the path simply is wrong!

Songo
  • 5,618
  • 8
  • 58
  • 96
0

Double check that the paths exist by simple echoing $filePath. If this checks out to be okay then ensure that the 'user' (apache, www-data, for example) have enough privileges. If you are not sure who your server is operating as you can simply debug by echoing whoami

Lloyd Moore
  • 3,117
  • 1
  • 32
  • 32