mbch
mbch

Reputation: 13

Getting an error when trying to add component to AppController in CakePHP

Im trying to add a SessionComponent to my controller in order to able to change the language of my app on the fly. The following snippet (specifically line 3) is the code i've tried according to http://book.cakephp.org/2.0/en/controllers/components.html#using-components

class AppSettingsController extends AppController
{
    var $components = array('Session');

But when i try to run any of the actions of my Controller i get:

SessionComponent could not be found.

Create the class SessionComponent below in file:         
src/Controller/Component/SessionComponent.php

As if the SessionComponent doesn't exist. All answers i have been able to find say that what i have already done ought to work. Do you have any idea what i might have missed or what i should look into to fix it?

Upvotes: 1

Views: 1078

Answers (1)

Salines
Salines

Reputation: 5769

From your post I conclude that you are referred to a CakePHP 2 documentation, but error message telling us that you are using CakePHP 3!

src/Controller/Component/SessionComponent.php

cakephp 3 has the following components:

  • Authentication
  • Cookie
  • Cross Site Request Forgery
  • Flash
  • Security
  • Pagination
  • Request Handling

and here is how to use sessions in your application:

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

Upvotes: 1

Related Questions