Here it is: <?php /** * Application level Controller * * This file is application-wide controller file. You can put all * application-wide controller-related methods here. * * PHP 5 * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package app.Controller * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */
/** * Application Controller * * Add your application-wide methods in the class below, your controllers * will inherit them. * * @package app.Controller * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller */ App::uses('Controller', 'Controller'); class AppController extends Controller { public $components = array( 'Session', 'Auth' => array( 'loginRedirect' => array('controller' => 'posts', 'action' => 'index'), 'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home') 'authorize' => array('Controller') // Added this line ) ); public function beforeFilter() { $this->Auth->allow('index', 'view'); } public function isAuthorized($user) { // Admin can access every action if (isset($user['role']) && $user['role'] === 'admin') { return true; } // Default deny return false; } } On Wednesday, 19 December 2012 19:46:02 UTC, jsundquist wrote: > > What does your current AppController look like? > > A stripped down version should look like this > > <?php > App::uses('Controller','Controller'); > class AppController extends Controller{ > } > > > > On Wed, Dec 19, 2012 at 1:38 PM, OxfordRob <[email protected]<javascript:> > > wrote: > >> @jsundquist - Thank you - that makes sense, I can see that information at >> the part of the error string. >> >> If I look at my cake folder structure, the file seems to be there (see >> attached picture). I am sure that file contains the class definition: >> >> class AppController extends Controller { ... etc. >> >> But it does not seem to be found by cake. >> >> I would think that somehow I have set it up so that cake is looking in >> the wrong place for this file. But that seems odd as the early part of the >> blog tutorial was working before I stated adding the authentication code. >> >> >> >> >> On Wednesday, 19 December 2012 19:04:10 UTC, jsundquist wrote: >> >>> The message is still pretty clear. That's a standard php debug message. >>> No way of changing the information present. >>> >>> As far as what that is telling you, its saying it still cannot find your >>> AppController. >>> On Dec 19, 2012 12:55 PM, "OxfordRob" <[email protected]> wrote: >>> >>>> @jsundquist - that was helpful, thank you. I had deleted the file - and >>>> the one I had created was missing: >>>> >>>> App::uses('Controller', 'Controller'); >>>> >>>> I am still seeing the long string of error messages however. >>>> >>>> "Fatal error: Class 'AppController' not found in >>>> /var/www/cakephp-2.3.0-RC1/**lib/Cake/Controller/**CakeErrorController.php >>>> on line 31 Call Stack: 0.0009 354512 1. {main}() >>>> /var/www/cakephp-2.3.0-RC1/ >>>> **app/webroot/index.php:0 0.0896 2939480 2. " etc.... >>>> >>>> I am finding it very hard to make any sense of these error messages. >>>> They are no very 'diagnostic'. Is there any way of getting more useful >>>> information about where the error might be? I can't see any of my file >>>> names in there, and I can't even see where one error item starts and >>>> another ends >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Wednesday, 19 December 2012 14:27:34 UTC, jsundquist wrote: >>>>> >>>>> The AppController.php is part of the default download of CakePHP in >>>>> all versions. I just downloaded a fresh copy of CakePHP 2.3.0-RC1 and >>>>> within the app/Controllers directory there is in fact an >>>>> AppController.php >>>>> file. You shouldn't need to re-create the file unless you deleted it. >>>>> >>>>> >>>>> On Wed, Dec 19, 2012 at 8:23 AM, OxfordRob <[email protected]> wrote: >>>>> >>>>>> As a follow up....I am suspicious in this area.... >>>>>> >>>>>> The tutorial says "To add this component to your application *open*your >>>>>> app/Controller/AppController.**p**hp file and *add* the following >>>>>> lines:" >>>>>> >>>>>> But this is the first mention of an 'AppController.php' file. >>>>>> >>>>>> So I just created an 'AppController.php' file and put in the code, >>>>>> but that does not feel right to me. >>>>>> >>>>>> I already have a 'UsersController.php' file that contains the class >>>>>> definition: >>>>>> >>>>>> class UsersController extends AppController >>>>>> >>>>>> So that makes me thing that 'AppController' is a pre-defined class in >>>>>> cake. Am I meant to be overloading this class? >>>>>> >>>>>> Something seems wrong. >>>>>> >>>>>> Any ideas please? >>>>>> >>>>>> >>>>>> >>>>>> On Wednesday, 19 December 2012 12:24:34 UTC, OxfordRob wrote: >>>>>>> >>>>>>> Folks, >>>>>>> >>>>>>> I successfully worked through the blog tutorial and everything >>>>>>> worked fine. >>>>>>> >>>>>>> I then moved onto the Authentication example / tutorial here...but >>>>>>> can't make it work.. >>>>>>> >>>>>>> http://book.cakephp.org/2.0/**en****/tutorials-and-examples/**blog-* >>>>>>> *a**uth-example/auth.html<http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html> >>>>>>> >>>>>>> I get a gibberish error message when I access the page... (Copied >>>>>>> below) which does not give me any real clues about what I have done >>>>>>> wrong. >>>>>>> >>>>>>> Does anybody know where to download the full source code for this >>>>>>> example? Or, if you have made this work, would you post it please? >>>>>>> >>>>>>> Any clues about how to read the error message below, and where I >>>>>>> might start looking would be very gratefully received! >>>>>>> >>>>>>> I have attached zip of my /app directory. >>>>>>> >>>>>>> Thanks for any help! >>>>>>> >>>>>>> >>>>>>> *Error message:* on accessing URL: http://localhost/cakephp-2.3.**0* >>>>>>> ***-RC1/users/add <http://localhost/cakephp-2.3.0-RC1/users/add> >>>>>>> >>>>>>> Fatal error: Class declarations may not be nested in >>>>>>> /var/www/cakephp-2.3.0-RC1/**lib****/Cake/Error/**ExceptionRenderer. >>>>>>> ****php on line 55 Call Stack: 0.0014 354512 1. {main}() >>>>>>> /var/www/cakephp-2.3.0-RC1/**app****/webroot/index.php:0 0.1175 >>>>>>> 2937464 2. Dispatcher->dispatch() /var/www/cakephp-2.3.0-RC1/**app** >>>>>>> **/webroot/index.php:97 0.1438 3490652 3. >>>>>>> Dispatcher->_getController() /var/www/cakephp-2.3.0-RC1/**lib**** >>>>>>> /Cake/Routing/Dispatcher.**php:**1**52 0.1438 3490652 4. >>>>>>> Dispatcher->_loadController() /var/www/cakephp-2.3.0-RC1/**lib**** >>>>>>> /Cake/Routing/Dispatcher.**php:**2**28 0.1440 3491896 5. >>>>>>> class_exists() /var/www/cakephp-2.3.0-RC1/**lib**** >>>>>>> /Cake/Routing/Dispatcher.**php:**2**59 0.1440 3492168 6. >>>>>>> App::load() /var/www/cakephp-2.3.0-RC1/**lib****/Cake/Core/App.php:0 >>>>>>> 0.1458 3537372 7. App::shutdown() /var/www/cakephp-2.3.0-RC1/**lib** >>>>>>> **/Cake/Core/App.php:0 0.1468 3537344 8. App::_checkFatalError() >>>>>>> /var/www/cakephp-2.3.0-RC1/**lib****/Cake/Core/App.php:899 0.1470 >>>>>>> 3538456 9. call_user_func() >>>>>>> /var/www/cakephp-2.3.0-RC1/**lib****/Cake/Core/App.php:926 >>>>>>> 0.1470 3538500 10. ErrorHandler::handleError() >>>>>>> /var/www/cakephp-2.3.0-RC1/ >>>>>>> **lib****/Cake/Core/App.php:0 0.1471 3538992 11. ErrorHandler::** >>>>>>> handleFatalError****() /var/www/cakephp-2.3.0-RC1/**lib**** >>>>>>> /Cake/Error/ErrorHandler.**php:**1**61 0.1481 3548532 12. >>>>>>> call_user_func() /var/www/cakephp-2.3.0-RC1/**lib**** >>>>>>> /Cake/Error/ErrorHandler.**php:**2**11 0.1481 3548560 13. >>>>>>> ErrorHandler::handleException(******) /var/www/cakephp-2.3.0-RC1/** >>>>>>> lib****/Cake/Error/ErrorHandler.**php:0 0.1488 3550236 14. >>>>>>> App::load() /var/www/cakephp-2.3.0-RC1/**lib****/Cake/Core/App.php:0 >>>>>>> >>>>>>> >>>>>>> -- >>>>>> Like Us on FaceBook >>>>>> https://www.facebook.com/**CakeP**HP<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 [email protected]. >>>>>> To unsubscribe from this group, send email to cake-php+u...@** >>>>>> googlegroups.com**. >>>>>> Visit this group at >>>>>> http://groups.google.com/**group**/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en> >>>>>> . >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>> Like Us on FaceBook >>>> https://www.facebook.com/**CakePHP<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 [email protected]. >>>> To unsubscribe from this group, send email to cake-php+u...@** >>>> googlegroups.com. >>>> Visit this group at >>>> http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en> >>>> . >>>> >>>> >>>> >>> -- >> 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 [email protected]<javascript:> >> . >> To unsubscribe from this group, send email to >> [email protected] <javascript:>. >> Visit this group at http://groups.google.com/group/cake-php?hl=en. >> >> >> > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en.
