-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional include of config/laminas-cli.php or something similar #78
Comments
There's a way to do this as of 1.1.0. As of 1.1.0, you can specify the <?php // in config/clear-cache-container.php
use Laminas\Mvc\Service\ServiceManagerConfig;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;
$config = require __DIR__ . '/application.config.php';
$devConfig = __DIR__ . '/development.config.php';
if (file_exists($devConfig)) {
$devConfig = include $devConfig;
$config = ArrayUtils::merge($config, $devConfig);
}
$config['modules_listener_options'] => [
'config_cache_enabled' => false,
'module_map_cache_enabled' => false,
];
$container = new ServiceManager();
(new ServiceManagerConfig($config['service_manager'] ?? []))->configureServiceManager($container);
$container->setService('ApplicationConfig', $config);
$container->get('ModuleManager')->loadModules();
return $container; Then, when calling laminas-cli for such operations, pass the location of this file: $ ./vendor/bin/laminas-cli --container ./config/clear-cache-container.php {command...} |
The example must be added to the documentation. |
A small correction to above code, that I successfully implemented in my project. Thx for the help! <?php // in config/clear-cache-container.php
use Laminas\Mvc\Service\ServiceManagerConfig;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;
$config = require __DIR__ . '/application.config.php';
$devConfig = __DIR__ . '/development.config.php';
if (file_exists($devConfig)) {
$devConfig = include $devConfig;
$config = ArrayUtils::merge($config, $devConfig);
}
$configDisableCaches = [
'modules_listener_options' => [
'config_cache_enabled' => false,
'module_map_cache_enabled' => false,
]
];
$config = ArrayUtils::merge($config, $configDisableCaches);
$container = new ServiceManager();
(new ServiceManagerConfig($config['service_manager'] ?? []))->configureServiceManager($container);
$container->setService('ApplicationConfig', $config);
$container->get('ModuleManager')->loadModules();
return $container;
` |
This feature should be added to laminas-cli, the current solution is only a workaround. |
Feature Request
Summary
For some of the logic of console commands it would be good and safe to be able to include an additional config file to override module options.
In my specific case I use console command to clean caches and in case some of the module listener caches are horribly invalid, my command would break. By including additional config file, I could implement a safety net by including following lines, which would prevent those caches to be loaded even if they are enabled globally.
The text was updated successfully, but these errors were encountered: