dsgdhf5674 2012-07-22 02:35
浏览 29

使用MAMP在本地设置远程PHP网站的类错误

I've worked to narrow down the list of possible problems with a remote website I've been asked to duplicate locally.

  • I've updated the relative/absolute paths across the entire website.
  • I've downgraded MAMP to an earlier version of PHP.
  • I've confirmed file permissions are the same on local as remote.

I'm confused as to why if the exact structure of the website is duplicated locally, why the code would have a Fatal error. How can I debug further or improve my "download" of the website to the local MAMP directory?

Notice: Undefined index: errors in /Applications/MAMP/htdocs/core/config/config.php on line 21 2 Warning require_once(index.php) [function.require-once]: failed to open stream: No such file or directory /Applications/MAMP/htdocs/core/config/config.php 116

Fatal error: require_once() [function.require]: Failed opening required 'index.php' (include_path='/Applications/MAMP/htdocs/core/classes/:/Applications/MAMP/htdocs/view/classes/:/:/:/Applications/MAMP/htdocs/core/pear/') in /Applications/MAMP/htdocs/core/config/config.php on line 116

This is the autoload function that causes the problem - I just can't figure out why:

`//AUTOLOAD
function __autoload($class_name)
{
    if($GLOBALS['show_dev'])
    {
        if(!isset($GLOBALS['starttime'])) {
            $GLOBALS['starttime'] = microtime(true);
        }
        $stack = array();
        foreach(debug_backtrace() as $stack_item) {
            $stack[] = $stack_item['file'] . ': ' . $stack_item['function'] . ': ' .                        $stack_item['line'];
        }
        $debug =  array(
            'Loading Class' => $class_name,
            'Class Loaded at' => number_format(microtime(true) - $GLOBALS['starttime'], 4, '.', ''), 
            'Memory (MB) used before class load' => (memory_get_usage() / (1024 * 1024)),
            'Current Stack Trace'=> implode("<br />", $stack)
        );

        $GLOBALS['debug'][] = $debug;
    }
    echo $class_name;
    require_once($class_name . ".php");
}`

After reviewing the setup of the constant variable definitions, I noticed the "realpath" function is used - why is realpath needed in this scenario?

` function setConstants() {

    if (!$this->info['constants'] || $GLOBALS['nocache'])
    {
        $this->info['constants'] = array
        (
            'SECTION'       => $this->section,
            'CONST_DEFINED' => true,
            'PEAR_ROOT'     => "/Applications/MAMP/htdocs/core/pear/",
            'SERVERS'       => "localhost:8888",

            'DOCUMENT_ROOT' => realpath('/Applications/MAMP/htdocs/view/') . "/",           
            'CORE_ROOT'     => realpath('/Applications/MAMP/htdocs/core/') . "/",           
            'CLASS_PATH'    => realpath('/Applications/MAMP/htdocs/classes/') . "/",            
            'CORE_CLASS_PATH'   => realpath('/Applications/MAMP/htdocs/core/classes/') . "/",

            'EMAIL_DATA_PATH'   => realpath('/Applications/MAMP/htdocs/core/emails/data/') . "/",

            'CORE_DATA_PATH'    => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/data/') . "/",
            'CORE_ACTION_PATH'  => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/actions/') . "/",
            'CORE_CONTROL_PATH' => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/controllers/') . "/",
            'CORE_HTML_PATH' => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/html/') . "/",

            'COMPONENT_DATA_PATH'   => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/data/components/') . "/",
            'COMPONENT_HTML_PATH' => realpath('/Applications/MAMP/htdocs/view/'.$this->section.'/html/components/') . "/",              
        );

        //$GLOBALS['cache']->set($this->cache_file_name,$GLOBALS['info'],1);
    }
}
  • 写回答

1条回答 默认 最新

  • dtjbcda841554 2012-07-24 13:16
    关注

    Read this SO post. PHP Zend require_once. From what you posted, it seems you don't have a realpath set. If so, this would cause the failure.

    评论

报告相同问题?

悬赏问题

  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀