使用phpdbg调试codeigniter

时间:2015-06-24 08:15:43

标签: php codeigniter phpdbg

我正在尝试基于CodeIgniter(2.x)框架调试Web应用程序。我已经尝试了var_dumping $ _SERVER并在我的调试会话开始时重新创建它(bootstrapping phpdbg)。

$ phpdbg -e index.php
phpdbg> ev require('boostrap.php');
phpdbg> run

然而它给了我404.即使通过浏览器请求页面给我正确的结果。有人可以告诉我如何正确引导phpdbg所以它在codeigniter加载正确的页面?这是我的自举代码,如果有帮助的话。

<?php
$_SERVER = array (
    'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv: 38.0) Gecko/20100101 Firefox/38.0',
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
    'HTTP_ACCEPT_ENCODING' => 'identity,gzip,deflate',
    'HTTP_CONNECTION' => 'keep-alive',
    'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    'SERVER_SIGNATURE' => '<address>Apache/2.4.12 (Ubuntu) Server at api.timzwart.local.mybit.nl Port 80</address>',
    'SERVER_SOFTWARE' => 'Apache/2.4.12 (Ubuntu)',
    'SERVER_NAME' => 'api.timzwart.local.mybit.nl',
    'SERVER_ADDR' => '192.168.1.35',
    'SERVER_PORT' => '80',
    'REMOTE_ADDR' => '192.168.1.35',
    'DOCUMENT_ROOT' => '/var/www/vhosts/api.timzwart.local.mybit.nl',
    'REQUEST_SCHEME' => 'http',
    'CONTEXT_PREFIX' => '',
    'CONTEXT_DOCUMENT_ROOT' => '/var/www/vhosts/api.timzwart.local.mybit.nl',
    'SERVER_ADMIN' => 'webmaster@localhost',
    'SCRIPT_FILENAME' => '/var/www/vhosts/api.timzwart.local.mybit.nl/index.php',
    'REMOTE_PORT' => '40706',
    'GATEWAY_INTERFACE' => 'CGI/1.1',
    'SERVER_PROTOCOL' => 'HTTP/1.0',
    'REQUEST_METHOD' => 'GET',
    'QUERY_STRING' => '',
    'REQUEST_URI' => '/events/185151',
    'SCRIPT_NAME' => '/index.php',
    'PATH_INFO' => '/events/185151',
    'PATH_TRANSLATED' => 'redirect:/index.php/events/185151/185151',
    'PHP_SELF' => '/index.php/events/185151',
    'REQUEST_TIME_FLOAT' => 1435128205.281,
    'REQUEST_TIME' => 1435128205,
    'REDIRECT_URL' => '/events/185151',
    'REQUEST_URI' => '/events/185151',
    'argv' => array('events','185151'),
);
?>

2 个答案:

答案 0 :(得分:0)

好吧,你总是可以从phpdbg cli检查打印那个常量,看看它是否定义了。您必须开始在codeigniter代码上创建中断..找到文件:返回404的行并在那里或之前添加一个中断并逐步进行,如果缺少某些内容,您将会发现。

答案 1 :(得分:0)

一个可能的解决方案,如果您可以编辑框架本身的版本,那就是查找所有引用输入法的行并编辑它们以接受一些伪造的debuging常量。它变得像这样。然后,您可以在实际调试之前在phpdbg中使用ev设置常量。

system/core/Input.php:      return (!defined('DEBUGGING_FAKE_WEBREQUEST') AND (php_sapi_name() === 'cli' OR defined('STDIN')));
system/core/URI.php:            if (!defined('DEBUGGING_FAKE_WEBREQUEST') AND (php_sapi_name() == 'cli' or defined('STDIN')))