cakephp - 为什么一些变化不会发生,直到我切换调试到3? [英] cakephp - why do some changes NOT happen until I switch debugging to 3?

查看:139
本文介绍了cakephp - 为什么一些变化不会发生,直到我切换调试到3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我会在本地实现更改,他们工作正常,我将它们复制到我的远程Web服务器,更改被忽略。 (代码是相同的)

Sometime I will implement changes locally and they work fine, I copy them to my remote webserver and the changed are ignored. (The code is identical.)

我进入core.php,调试到3,再次检查...它工作!

I go into core.php, change debugging to 3, check again... it works!

我有一个感觉,这是与缓存有关,但我不知道究竟要改变。

I have a feeling it's something to do with cache but I don't know what exactly to change.

推荐答案

CakePHP的缓存位于 / app / tmp / cache 中。目录结构如下所示:

CakePHP has a cache located in /app/tmp/cache. The directory structure looks like this:

# /app/tmp/cache
# /app/tmp/cache/models
# /app/tmp/cache/persistent
# /app/tmp/cache/views


b $ b

通常遇到的主要问题是模型缓存。当调试关闭(即在生产中)并且您导致CakePHP分派时,它内省了所有数据库表的模式,并将它们存储在上面的 models 文件夹中的平面文件中。如果你不删除这个文件夹中的文件,CakePHP将开始说明模型/表/字段不存在,当他们清楚地在你的数据库。

The main issue usually experienced is with the model cache. When debug is off (ie. in production) and you cause CakePHP to dispatch, it introspects the schema of all your database tables and stores these in flat files in the models folder above. If you do not delete the files in this folder, CakePHP will start to say models/tables/fields don't exist when they clearly do in your database.

如果你在应用程序中启用视图缓存,当第一次呈现视图时,CakePHP将编译平面文件到 views 文件夹,以防止在下一个请求中再次呈现这些视图。

If you enable view caching in your application, when views are rendered for the first time CakePHP will compile flat files to the views folder to prevent having to render these views again on the next request.

在CakePHP的引导过程中,它必须确定您在安装过程中使用的目录结构,然后才能访问重要的文件(如 database.php )。因此,CakePHP将生成到 persistent 目录的缓存文件,其中包含每个重要目录和文件,您使用的任何插件以及您创建的任何地方的绝对路径因此,您可以在不重新整理 .pot 文件的情况下,在不同语言之间快速翻译您的应用程序。

During CakePHP's bootstrap process it has to determine the directory structure you are using in your installation before it can access important files (like database.php). As such, CakePHP will generate cache files to the persistent directory with the absolute paths to each and every important directory and file, any plugins you are using and even any localisations you have created so it can quickly translate your application between languages without reparsing .pot files.

记住在您对生产中的应用程序进行代码更改时,删除这些目录中的所有文件,或将其添加为部署机制

So, simply put, you have to remember to delete all of the files in these directories whenever you make code changes to an application that is in production, or add this as part of your deployment mechanism. You must not delete any of the directories however.

将调试更改为3的原因是因为当调试模式打开时在任何值更大的零)缓存被清除和重新生成在每个请求,但是 - 这个工作 - 这是不容易的自动化。

The reason changing debug to 3 works for you is because when debug mode is turned on (at any value greater zero) the cache is cleared and regenerated on every request, but - while this works - it is not easy to automate.

有很多方法以编程方式执行此操作(包括 shell命令 CakePHP插件 Capistrano配置,Ant文件 - 但也可以手动执行。

There are a number of ways to do this programmatically - including shell commands, CakePHP plugins, Capistrano configs, Ant files - but one can also just do so manually.

这篇关于cakephp - 为什么一些变化不会发生,直到我切换调试到3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆