1

I want to have a bunch of settings in my module, and they should be writable from the App. Since they're application settings, I thought a table for it would be not very efficient (it would only have one row).

I found the Zend module Zend\Config, which seems to be able to to write config files, which can in turn be used by Zend.

It is advisable to write into the module.config.php? Or into a different file? Can I still load it into the standard module config?

I am pretty new to Zend and this fully modular approach, so I'd like some clarification on that.

Lanbo
  • 15,118
  • 16
  • 70
  • 147
  • Performance wise, you could always just cache the settings to avoid hitting the database on every request. I would avoid using `module.config.php` if I could get away with it, just to keep writing simple. That wouldn't be all that difficult anyways, but that is just my personal preference. Perhaps you could add an event listener to the [loadModules.post](http://framework.zend.com/manual/2.0/en/modules/zend.module-manager.module-manager.html#module-manager-events) event where you can read your configuration file such that it will be merged in with the other configuration. – ba0708 Feb 10 '13 at 00:22
  • If you are writting config at rundtime, you're most likely abusing and creating global state like with the Registry pattern. Why do you want to write config? – markus Feb 10 '13 at 11:39
  • @markus It was probably just ambigious phrasing. What I want is that the user can change these options in a backend view or something. So they don't have to change the actual file, but to have a nice form for it. – Lanbo Feb 10 '13 at 12:20
  • Then I'd split the config into user editable config and the rest and use the Hydrator approach to populate the form and save to config again. – markus Feb 10 '13 at 13:07
  • Store any user options in the database, I certainly wouldn't write to the php config files you are asking for trouble :) – Andrew Feb 11 '13 at 10:44

1 Answers1

0

You should never write into the module directory itself. Instead, have a data directory, e.g. at the root of your application, and put written configuration files in there.

DASPRiD
  • 1,673
  • 11
  • 16