Skip to content
This repository has been archived by the owner on Jun 4, 2020. It is now read-only.

Enable different enviroments #6

Open
ThaDafinser opened this issue Feb 26, 2014 · 1 comment
Open

Enable different enviroments #6

ThaDafinser opened this issue Feb 26, 2014 · 1 comment

Comments

@ThaDafinser
Copy link
Contributor

We can now enable/disable a development mode with this module, but this only works for the "base configuration". Also if you have more than 2 enviroment, its stuck because some modules are only needed in production.

When using other components which have enviroment settings, this is also not enough:

  • DoctrineORMModule -> caching / database
  • Zend\Translate -> caching
  • Zend\View -> error reporting
  • ...

You can achieve this with config/autoload/local.php...but than you have to it manually currently.

_So my suggestion is:_

  • copy needed enviroment *config/autoload/*.local.php.dist to config/autoload/local.php
  • copy needed enviroment config/*.config.php.dist to config/enviroment.php

_New command (replacing the old):_

  • php index.php enviroment [none|development|production|testing|....]
  • or php index.php switch [none|development|production|testing|....]
  • or php index.php switch enviroment [none|development|production|testing|....]
  • or php index.php enable enviroment [none|development|production|testing|....]
    (if none is provided, just remove the current enabled files)

_the config/autoload folder could look like_

  • global.php
  • development.local.php.dist
  • production.local.php.dist
  • testing.local.php.dist

E.g. I you only want to use EdpSuperluminal modul in production, you can move it to config/production.config.php.dist which will be copied to config/enviroment.php (instead of development.config.php) with the command above

Things to keep in mind:

  • overwrite existing config/autoload/local.php and config/enviroment.php dangerous? Maybe a "force" parameter?

_Good idea / bad idea? Feedback?_

Pinging @akrabat @ezimuel @weierophinney
(sorry for the pings, but since this modules is forket, i though it's a good idea)

@weierophinney
Copy link

copy needed enviroment config/*.config.php.dist to config/enviroment.php

This won't do anything for the application, however, as the config file is not in the glob path. Did you mean to do it as environment.local.php instead? Also, one thing to consider is the order -- do you want this to match before or after a local.php file, if defined?

The other, much larger, problem with this is that it encourages having potentially security-sensitive data saved in the filesystem. This is something we were explicitly discouraging with the global/local split, and went so far as to add anything matching config/autoload/*local.php to the .gitignore.

Tools such as Puppet, Chef, etc. exist to help you push environment-specific configuration files to your deployment platform, allowing you to put those in a local.php or similar.

The concept for "development mode" was, honestly, to answer the question of "how do I enable some modules in development mode, but not in production?" If you need something like what you describe above, it falls outside of that scope, and, to my thinking, promotes a practice we don't want to encourage.

(BTW, I encourage you to raise discussions like this at zfcampus/zf-development-mode, where we've forked this (with @akrabat 's blessing) for use in Apigility and ZF2 in general.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants