Question

I'm having trouble to find those information .

In ZF1 is possible to divide the environments in development, production , staging and testing.

In ZF1 I have a database configuration different for each type of environmental data. I have the 4 settings ready and written to the file application.ini

In ZF2 , I 'm in doubt on how to create these 4 environments , I actually use 4 in my application cycle .

on the / config / autoload i have a lot of files .

cache.local.php
global.php
zenddevelopertools.local.php
zfcuser.global.php

The documentation says: By default , this application is configured to load all configs in

' . / config / autoload / { *. } { global, local } . ' php

The 2 indicates that only environments , global and local to my development machine .

My main questions :

1 - how framework recognizes the environments , such as Global / Local ? ZF1 was set in the index.php via line

defined (' APPLICATION_ENV ' )
    | | Define (' APPLICATION_ENV '
              ( getenv ( ' APPLICATION_ENV ' ) ? getenv ( ' APPLICATION_ENV ' )
                                         ' Production '));

which does not actually appear in ZF2 .

2 - How can expand these 2 environments to 4 ?

Global - Production
Staging - Staging is AB test
Testing - For PHPUnit Testing Full ( i test dbs Also , future I\'ll go with sqlite but today was mysql )
Development - With dummy data created to have life and system run properly on my computer .

3 - I have not found a clear way to declare a development environment for testing . If you need to set the ENV through htaccess , it will only work for apache correct ? as is the time of setting tests in PHPUnit ? And how to load pro ZF2 exactly the credentials of test benches ?

Was it helpful?

Solution

ZF2 doesn't have an in-built concept of different environments. By default the 'global' config files are checked in to source control but the 'local' configs are not. So the idea is most of your configuration is in the global files, but environment-specific config goes in the local files.

Let's say your cache.local.php config contains env-specific stuff like paths. If so, you would have this file on production, staging and development; but its contents would be different.

If you really want to stick with the ZF1 way, and want your environment-specific config in source control, this can easily be achieved too. See this blog post: http://blog.evan.pro/environment-specific-configuration-in-zend-framework-2 . You'll need to define the APPLICATION_ENV constant for this to work (you can cut'n'paste the line from your question ininto public/index.php).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top