2016-08-29 26 views
1

我試圖將SessionComponent添加到我的控制器以便能夠在運行中更改我的應用程序的語言。下面的代碼片段(特別是3號線)是我根據http://book.cakephp.org/2.0/en/controllers/components.html#using-components嘗試將組件添加到CakePHP中的AppController時出現錯誤

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不存在。我已經能夠找到所有的答案,說我已經完成了應該工作。你有什麼想法我可能錯過了什麼,或者我應該考慮修復它?

+0

您有哪些CakePHP的版本?在CakePHP v2.7中。 FlashComponent是爲SessionComponent添加的 – Provie9

回答

0

從你的文章中,我斷定你被稱爲一個CakePHP的2文件,但錯誤信息,告訴我們您正在使用CakePHP的3

SRC /Controller/Component/SessionComponent.php

CakePHP的3具有以下組件:

  • 認證
  • 餅乾
  • 跨站請求僞造
  • 閃存
  • 安全
  • 分頁
  • 請求處理

,這裏是如何使用會話在您的應用程序:

http://book.cakephp.org/3.0/en/development/sessions.html#accessing-the-session-object

+1

謝謝!我偶然看到錯誤的文檔(即2.x書)。 – mbch

相關問題