I am working on a project using CakePHP and have been trying to update some views. The file uploads to the server correctly but the system seems to serve the old version. I am kind of new to Cake so I'd appreciate any pointers.
Thanks!
I experienced the same thing. The trick is to clear out all of $YOUR_APP_FOLDER/tmp/cache when deploying new code, to erase any conflicting cache.
cd $YOUR_APP_FOLDER
rm -f tmp/cache/*/*
It could be that view-caching is enabled, check core.php for
define ('CACHE_CHECK', true);
Where are you putting the views? Also, make sure the /tmp/cache/ folder doesn't have any lingering crap in it that might be getting rendered.
Edit:
If you set the debug level in config/core.php to something higher than 0, caching will be disabled and you'll get nice error messages if something poops the bed.
The only way to ignore cache of views is uncommenting
Configure::write('Cache.disable', true);
in core.php
Related
I am trying to figure out where to setup my memcached configuration in CakePHP 2. Both core.php and bootstrap.php have sections to set up any cache such as memcached, but I still haven't figured out which file to use.
Also the CakePHP documentation is not so clear about this in my eyes.
Could anyone point out what part of the memcached configuration goes into which file please.
Really, you can place configuration values anywhere you would like, even in their own files as long as you load them in core.php or bootstrap.php. However, the default 2.0 core.php file states that other cache configurations should be in bootstrap.php as stated here: https://github.com/cakephp/cakephp/blob/master/app/Config/core.php#L349.
FWIW, we load addition configuration files depending on an environment variable (APP_ENV) as well as a location specific one that overrides all others. We call it core-local.php but the name doesn't really matter as long as it's not tracked in your VCS.
Edit:
Here's how we load environment specific configs. This is towards the end of our core.php so that the configs loaded after it are not overwritten.
$env = getenv('APP_ENV');
if (is_readable(dirname(__FILE__) . "/core-{$env}.php")) {
Configure::load("core-{$env}");
}
End Edit
Lastly, the CakePHP docs are really easy to edit and PRs are very welcome. If you think you can clarify the docs just click on the link at the top of the documentation page and edit away. You can then use the GitHub UI to submit the PR. No editor or git binary is necessary.
I'm trying to understand why I have so many errors on the remote server but on local server everything's fine.
Any idea why I'm getting all of these error?
Thank you in advance!
looks like there's a mess with the cache files. Try disabling the cache in your remote app.
Do this in /app/Config/core.php
Look for the following:
//Configure::write('Cache.disable', true);
and remove the // to make it works.
Best,
Ok guys, I have no idea what generated these issues but after changing to a new hosting the issues disappeared. Always check online for hosting reviews to make sure it's a good one or you'll end up with some odd things happening on your website. Thanks y'all for your help and time.
I have finally my project ready to go live, is there a check list of things to go through before uploading the files to the webserver?
Are there any Files or Folders to be deleted before going live.
Version of cake: 2.3.8
I found out to set the debug level to 0.
Set the cookie in core.php
Do I need to remove the following folders?
/app/Console
/lib/Cake/Test
/lib/Cake/TestSuite
Any other security advise please?
Thanks a lot.
Don't deploy anything to production that isn't needed. If your project doesn't require those folders to function, then don't deploy them.
Make sure to check out the short deployment guide from the cake docs.
Also here's a more general website launch checklist.
I recommend making sure your deployment process resets caches appropriately. This can differ depending on how you have things set up, but by default CakePHP uses a file cache. Regardless, it can really hose you to let the cache linger when things should be updated like model schema, etc. For example, see my answer to another StackOverflow question.
I need to log Fatal-errors of my website.
I normally check error.log and debug.log files for CakePHP errors.
But I found out that PHP related fatal errors aren't logged someplace.
It is also discussed in this thread.
I checked php.ini. IT has following lines:
log_errors = On
;error_log = filename
I don't have rights to change php.ini. I can ask admin to change this, but it seems like I need to ask him every time I need a change :) I also have concerns about performance. Whether logging errors can decrease performance or not?
So I find out that I can put following two lines inside my script to log errors and change folder or file name when I need.
ini_set("log_errors", 1);
ini_set("error_log", "/path/to/php-error.log");
So I want to know where to put this lines inside my codes? Should I put it inside AppController::beforeFilter ? Or is there a better place/solution in CakePHP 2 configuration?
this is an old thread.
in the meantime with cake 2.x errors are all logged in productive mode - so also fatal errors.
trigger one and check out your /tmp/logs/error.log
but you can easily find that out looking at the core code:
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Error/ErrorHandler.php#L189
There is framework defined configuration settings. You can use the Error Handling configuration class.
Here is changing fatal error behavior link, that will help you to achieve the same.
register_shutdown_function();
http://php.net/manual/en/function.register-shutdown-function.php
I would like to disable the cache for a self-developed Cake plugin. Is this possible and if so, how would I do this? The reason why is related to an earlier question of mine, where duplicate controller names break parts of my application which were working fine in 1.3.
I know one can disable the Cache by setting the following option in Core.php:
Configure::write('Cache.disable', true);
I thought it would be possible to do the same in PluginAppController.php in the beforeFilter or beforeRender method, but that doesn't seem to be working.
Does anybody know if it's possible to do from the PluginAppController or if there are any other options? Disabling the entire cache is very undesirable as it slows down the rest of the application considerably.
This sounds like poor application architecture. You shouldn't have to disable the cache -- which sounds like it is a bandaid for a larger problem. Why don't you simply rename one of the controllers or add some sort of pseudo namespace naming convention in your app to prevent the issue?