我试图添加一个SessionComponent到我的控制器,以便能够改变我的应用程序的语言。下面的代码片段(特别是第3行)是我根据http://book.cakephp.org/2.0/en/controllers/components.html#using-components
尝试过的代码class AppSettingsController extends AppController
{
var $components = array('Session');
但是当我尝试运行控制器的任何动作时,我得到:
SessionComponent could not be found.
Create the class SessionComponent below in file:
src/Controller/Component/SessionComponent.php
就好像SessionComponent不存在一样。我所能找到的所有答案都表明,我所做的应该是有效的。你知道我可能错过了什么,或者我应该研究什么来修复它吗?
从你的帖子,我得出结论,你是指一个CakePHP 2文档,但错误消息告诉我们,你正在使用CakePHP 3!
src /控制器/组件/SessionComponent.php
cakephp 3包含以下组件:
- 认证 饼干跨站点请求伪造Flash
- 安全
- 分页
- 请求处理
http://book.cakephp.org/3.0/en/development/sessions.html accessing-the-session-object