2

我正在尝试基于 CodeIgniter (2.x) 框架调试 Web 应用程序。我已经尝试过 var_dumping $_SERVER 并在调试会话开始时重新创建它(引导 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'),
);
?>
4

2 回答 2

0

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

于 2015-07-10T16:48:42.697 回答
0

如果您可以编辑框架本身的版本,一个可能的解决方案是查找所有引用输入法的行并编辑这些行以接受一些虚构的调试常量。变成这样。然后,您可以在实际调试之前在 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')))
于 2015-09-07T14:13:28.437 回答