将头扑在墙上以解决此错误。我在本地主机上使用带有MAMP的codeigniter 2。该站点可以在WAMP(Windows 10)上完美运行,并且所有配置都相同。
我有一个简单的登录表单,提交时甚至没有命中我的post方法,但显示错误:
Fatal error: Uncaught Error: Class 'CI_Controller' not found in /Applications/MAMP/htdocs/mysite/src/system/core/CodeIgniter.php:237
我已经在dologin函数中测试了var_dumps。有趣的是,如果我直接在地址栏中添加https://localhost/mysite/src/session/dologin,错误就会消失,并且显示var_dump的输出。
Core / CodeIgniter.php行235-238
function &get_instance()
{
return CI_Controller::get_instance();
}
登录表单
<form action="https://localhost/mysite/src/session/dologin" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username" />
<label for="password">Password</label>
<input type="password" id="password" name="password" />
<button type="submit">Login</button>
</form>
CI登录功能(正在加载登录视图)
public function login()
{
$this->output->enable_profiler(false);
$this->data['system_message'] = null;
if (file_exists(SYSTEM_MESSAGE)) {
$this->data['system_message'] = file_get_contents(SYSTEM_MESSAGE);
}
$this->template->write_view('content', 'session/login', $this->data);
$this->template->render();
}
CI登录表单发布功能
public function dologin()
{
global $pre_filter;
$username = $this->input->post('username');
$password = base64_encode($pre_filter['password']);
$auth = $this->rest->post('authentication/sessions', ['username' => $username, 'password' => $password, 'endpoint' => $this->sitecode]);
//...further processing
}
两个CI控制器功能都在此类中,该类扩展了自定义控制器。
class Session extends MySite_Controller {
}
注意:BASEPATH是正确的(通过多个调试var_dumps检查)$ config [‘base_url’] ='',设置为空白.htaccess设置正确,并且Apache的Rewrite模块已打开$ config [‘log_threshold’] = 0,日志已关闭
似乎可行
在system / core / CodeIgniter.php中,在第75行周围,更改:
set_error_handler('_exception_handler');
至...
set_exception_handler('_exception_handler');