This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'modules' => array( | |
'Application', | |
'MyModule1', | |
'MyModule2', | |
//and so on... | |
), | |
//... | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// dont return the array, just define a variable to use it later | |
$config = array( | |
'modules' => array( | |
'Application', | |
), | |
//... | |
) | |
// use this only for development | |
if(getenv('APPLICATION_ENV') == 'development'){ | |
$handle = opendir('./module'); | |
$modules = $config['modules']; | |
while (false !== ($entry = readdir($handle))) { | |
if ($entry != "." && $entry != ".." && is_dir('./module/'.$entry) && !in_array($entry, $modules)) { | |
$modules[] = $entry; | |
} | |
} | |
closedir($handle); | |
$config['modules'] = $modules; | |
} | |
return $config; |
When deploying to production just add your production modules in the original config array and its ready to work.
Update:
As Manuel Stosic pointed out in the ZF2 group in facebook, this is not a good approach if you you need to preserve loading order. This is intended to be use in your own modules while developing (i use this approach with a dev partner), if you are going to use zfcUser, etc... just put those modules in the original config array.
No hay comentarios.:
Publicar un comentario