MAMP 和代码点火器 - 简单表单发布返回 致命错误:未捕获错误:找不到类"CI_Controller"



用头撞墙来解决这个错误。我在本地主机上使用带有MAMP的codeigniter 2。该网站在WAMP(Windows 10(上运行良好,所有配置都是相同的。

我有一个简单的登录表单,在提交时甚至没有击中我的帖子方法,但显示错误:

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直接在我的地址栏里。

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的重写模块打开
$config['log_threshold']=0,日志关闭

这似乎适用于

在system/core/CodeIgniter.php中,在第75行左右,更改:

set_error_handler('_exception_handler');

到。。。

set_exception_handler('_exception_handler');

最新更新