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:
Connect Error: SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'xyz'
I still work on the same computer.
So what error it might be?
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
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.
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.
EDIT1: Here additional a screensot, which configuration files I use in which folders:
In my application.config.php the configuration links to:
'config_glob_paths' => [
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.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,
],
for me it looks correct. My database connection is in local.php
(for the production) and in local-development.php
(for the development mode).
If you use
development-mode enable
(Development) it meanconfig_cache_enabled
set tofalse
. So your new configuration likemodule
,services
,controllers
, etc will load byZF3
, becauseZF3
will not read the configuration fromcache
(indata/cache/*
).If
development-mode disable
(Production) configuration will be cached, so when you deploy your code with new configuration like I mention above, will not read byZF3
. BecauseZF3
still read the configuration incache
.I usually remove the cache when deploying to Production. Here the sample
shell script
I used for deployingSo, the main key, if you used
development-mode disable
, just remove thecache
after deploying the code.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.
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
andapplication.module.cache
as configured inconfig/application.config.php
.