ZF3开发模式VS生产模式 [英] ZF3 Development Mode VS Production Mode

查看:125
本文介绍了ZF3开发模式VS生产模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发模式下使用ZF3和代码.我按照本教程的建议进行了配置:

I use ZF3 and code in the development mode. I configured it like the tutorial suggests:

composer development-enable

因此,如果启用此模式,一切正常.如果禁用它,则会出现数据库连接错误,如下所示:

So everything works fine if this mode is enabled. If I disable it I get a database connection error, like this one:

连接错误:SQLSTATE [HY000] [1044]用户的访问被拒绝 ``@'localhost'到数据库'xyz'

Connect Error: SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'xyz'

我仍然在同一台计算机上工作.

I still work on the same computer.

那可能是什么错误?

主要主题是,如何在开发和生产之间进行更改的正确方法,composer语句是否也明确了使用生产配置文件?

The main topic would be, how is the right way to change between development and production, does the composer statement also make clear to use the production configfiles?

如果我通过作曲家更改了模式,我还需要做些什么?我真的很蓝眼睛,只要禁用它就足够了:

If I have changed the mode via composer, what do I have to do additional? I really blueeyed thought, it would be enough to just disable:

composer development-disable

我也必须重命名开发配置文件吗?我们谈论哪些文件?只是application-config.phpdevelopment-config.php吗?

Do I have to rename the development config files also? Of which files do we talk about? Is it just application-config.php and development-config.php?

我应该在哪里以及如何放置不同的数据库连接?现在,我使用上面看到的文件.

Where and how should I place the different database connections? I now use the files you see above.

最后,如何更改生产服务器上的模式?现在,我只是在开发系统上禁用了该模式,然后上传了Hole项目.之后,我只上传更改的文件.

And last, how to change the mode on the production server? I now just disabled the mode on my developmentsystem and then uploaded the hole project. Afterwards I only upload the changed files.

这里还有一个screensot,我在哪些文件夹中使用哪些配置文件:

Here additional a screensot, which configuration files I use in which folders:

在我的application.config.php中,配置链接到:

In my application.config.php the configuration links to:

 'config_glob_paths' => [
            realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
        ],

以及在我的development.config.php中的配置链接

and in my development.config.php the configuration links to

 'module_listener_options' => [
        'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'],
        'config_cache_enabled' => false,
        'module_map_cache_enabled' => false,
    ],

对我来说,它看起来正确.我的数据库连接位于local.php(用于生产)和local-development.php(用于开发模式).

for me it looks correct. My database connection is in local.php (for the production) and in local-development.php (for the development mode).

推荐答案

启用/禁用模式与具有/不具有config/development.config.php文件是一样的.

Enabling/Disabling the mode is just the same as having/not having the config/development.config.php file.

如果您仔细查看,您会看到开发模式禁用了缓存.

If you look closely, you'll see that the development mode disables the cache.

您的问题是,在配置不适合该环境的情况下,已创建了缓存文件(非开发人员模式).按照 config/application.config.php中的配置删除data/cache/application.config.cacheapplication.module.cache .

Your problem is that the cache files have been created (non dev mode) while the configuration wasn't fine for the environment. Remove data/cache/application.config.cache and application.module.cache as configured in config/application.config.php.

这篇关于ZF3开发模式VS生产模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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