Wednesday, December 26, 2012

Re: Properly setting up CacheHelper

as I stated above, it is vital that you always include all uses classes throughout your files.
so, no. it is not enough - as you just experienced yourself. it might work up to some point - and than it breaks.

the App::uses can be compared to require statements. If you don't tell cake what files are required it fill fail eventually.

same goes for helpers, models, behaviors, ...


Am Mittwoch, 26. Dezember 2012 16:18:55 UTC+1 schrieb Nvp:
Thank you, Mark. 
It solves the problem, but I was absolutely sure that it is enough to specify `App::uses('AppController', 'Controller');`  in the /Controller/AppController.php
I think they should definitely add the importance of inclusion of this fragment of code in the Cookbook.

On Wednesday, December 26, 2012 7:08:24 PM UTC+4, euromark wrote:
thats because you forgot a vital part above your 
class NewsController extends AppController {}

above it add `App::uses('AppController', 'Controller');`

It is important that you always specify all used classes in your files at the top.


Am Mittwoch, 26. Dezember 2012 16:00:40 UTC+1 schrieb Nvp:
Hi! I have a strange issue with CacheHelper and perhaps it's because I do some error in configuration.
For the first time I encountered this problem while working on my main project. 
After it, I have downloaded CakePHP 2.2.4 and created an app for testing.

As mentioned above I'm trying to use CacheHelper. 

#### What I did:
New CakePHP 2.2.4, freshly downloaded. No changes was made except of:

core.php:
I added Configure::write('Cache.check', true); as mentioned in the Cookbook

bootstrap.php: (It was already there, so I did not make any changes.)

Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));

Controller/NewsController.php – this is my controller for testing.

<?php
class NewsController extends AppController {
public $helpers = array('Cache');
public $cacheAction = array(
       'view' => 36000,
       'index'  => 48000
);

public function index() {

}

public function clear() {
clearCache();
}
}

View/News/index.ctp:

Things went OK!


#### What happened

On the first page load (domain.com/news) I can see my view rendered as expected.
If I try to access page for the second time I get the error:

Error: Class 'AppController' not found
File: ../app/Controller/NewsController.php
Line: 2

And as long as I did not clear the cache, I get the same error.
After clearing cache I can once again load page and after that everything is repeated and I get the same error.

Thanks in advance.

--
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: