Friday, December 21, 2012

Begginer's Lesson learned! [Solved] Authentication Tutorial

Thank you to jsundquist , crush, sams and cricket over the last few days for helping me with my Authentication tutorial problems. I fixed it this morning.

My take-away from this is a very general 'lesson learned' and  I thought I would share the knowledge for any other beginner who comes through here.

The error message I started with was:

PHP Fatal error: Class 'AppController' not found in /var/www/lib/Cake/Controller/CakeErrorController.php on line 31

PHP Stack trace:

PHP 1. {main}() /var/www/app/webroot/index.php:0

PHP 2. Dispatcher->dispatch() /var/www/app/webroot/index.php:97


This sent me on a 2-day joy-ride looking for, moving and changing access permissions to the 'AppController' class definition file. In the process of course I screwed up my configuration and got in a hopeless mess.

So this morning I re-built everything very carefully, followed the instructions to the letter....and got exactly the same error!

I was about to say "Enough cake for me"...but then remembered that "too much cake" is one of the shortest self-contradictory statements in the English Language.

I decided to copy back the original, distribution AppController.php file  - and the error message went away.

My conclusion was...this is not the fact that the file is missing, but class is not compiling successfully. WIth this in mind I took a look at the Apache Error log.....and this is what I found...

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /var/www/app/Controller/AppController.php on line 41

PHP Stack trace:

PHP 1. {main}() /var/www/app/webroot/index.php:0

PHP 2. Dispatcher->dispatch() /var/www/app/webroot/index.php:97

PHP 3. Dispatcher->_getController() /var/www/lib/Cake/Routing/Dispatcher.php:152

PHP 4. Dispatcher->_loadController() /var/www/lib/Cake/Routing/Dispatcher.php:228

PHP 5. class_exists() /var/www/lib/Cake/Routing/Dispatcher.php:259

PHP 6. App::load() /var/www/lib/Cake/Core/App.php:0

PHP 7. include() /var/www/lib/Cake/Core/App.php:560

PHP 8. App::load() /var/www/lib/Cake/Core/App.php:0

PHP Fatal error: Class 'AppController' not found in /var/www/lib/Cake/Controller/CakeErrorController.php on line 31

PHP Stack trace:

PHP 1. {main}() /var/www/app/webroot/index.php:0

PHP 2. Dispatcher->dispatch() /var/www/app/webroot/index.php:97


(This is where I should "Arghhhhh!")

The error message shown on the screen is not the complete error string!

I guess that Cake / PHP is only displaying the Fatal Error, and casually loosing the real error here. I.e. it was not that the file was missing or in the wrong place - but that the class definition had a simple syntax error in it (too trivial and embarrassing to mention here)

So here is my beginners lesson learned: Keep an eye on the Apache error log (obvious really). The message on the screen is not only formatted in a way that makes it hard to read - it my not be displaying all of the useful information you need to sort out the problem.

Rob




--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: