Tag Archives: Cakephp

Cake PHP first steps

So having gone through the Blog tutorial and the Simple authentication tutoiral, I have come across my first rode bump: a really ugly exception: PHP Fatal error: Class 'AppController' not found in /var/www/lib/Cake/Controller/CakeErrorController.php on line ...

At that I was completely lost. So I went for help from Mr. Google.

The first search result I have stumbled upon was in Italian, but I would never let such a trifle to stop me. I realized there may be a way to drill further down this error, if I set right my error handling level with the debugger: add (modify) this line in your app/config/core.php: Configure::write('debug', 2);

Unfortunately this line is already set in there.

So I went on for the second result. There I have found out that PHP5.4 would allow this syntax: $this->Auth->user()['role'] while in older version you would rather use: $user = $this->Auth->user()
$role = $user['role'];

I am not syaing this piece of info was completely irrelevant. It was in fact, indirectly. Because it taught me 2 things:

  1. Cake is looking for the error controller to alert about a problem, and at not finding it – would alert about the missing error handler. Instead of alerting about the actual probelm, it would whine about it’s issues with the error handling.
  2. Good to know you can use this syntax in new versions of PHP!

Off-course at this stage I am still at a loss about the issue that had caused all this in the first place. So I go for the 3rd, 4th … results, and I come across this very helpful link by Oxford Rob (from whom I have also borrowed the quotation) with some very usefull lead: It is all in the appcontroller.php file. Here’s where we start to debug.

So first stage is to set a new fresh copy of this file, instaed of the one we’re having – at doing that – the application is loading correctly. With that I get a couple of more civilized error messages that I am going to take care of later on.

So now I am going to add back gradually everything that was in the appcontroller so I am able to tell where exactly everything should fall apart. And here it is: public $components = array('DebugKit.Toolbar');

What is this DebugKit.toolbar – I really know nothing of. But at least I am able to go on and try to look it up. I am now left with two unsolved issues:

  1. The error handler issue is still not solved.
  2. I am left with a more civilized error message: Error: The application is trying to load a file from the DebugKit plugin on my application’s main page. So that’s probably the next thing I need to try and fix.