php - Zend Framework 2: Disable module on production environment -


ok, here's problem:

i have module in zend framework 2 application wish not include on production. therefore, made file inside config/autoload called local.php following content:

'modules' => array(     'application',     'my_local_module', ), 

while config/application.config.php contains:

'modules' => array(     'application', ), 

when try access module in url, 404 returned. however, when set modules inside application.config.php file, module displayed properly. environment variable set local.

put following lines in index.php:

<?php  // ...  // current environment (development, testing, staging, production, ...) $env = strtolower(getenv('application_env'));  // assume production if environment not defined if (empty($env)) {     $env = 'production'; }  // default config file $config = require 'config/application.config.php';  // check if environment config file exists , merge default $env_config_file = 'config/application.' . $env . '.config.php'; if (is_readable($env_config_file)) {     $config = array_merge_recursive($config, require $env_config_file); }  // run application! zend\mvc\application::init($config)->run(); 

then create different configuration files each environment.

application.config.php:

<?php  return array(     'modules' => array(         'application'     ),     'module_listener_options' => array(         'config_glob_paths' => array(             'config/autoload/{,*.}{global,local}.php'         ),         'module_paths' => array(             './module',             './vendor'         )     ) ); 

application.development.config.php:

<?php  return array(     'modules' => array(         'zenddevelopertools'     ) ); 

application.production.config.php:

<?php  return array(     'module_listener_options' => array(         'config_cache_enabled' => true,         'module_map_cache_enabled' => true,         'cache_dir' => 'data/cache/'     ) ); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -