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);
}
}