Skip to content

Commit

Permalink
feat: migrate config to application (dvsa/olcs-backend#78)
Browse files Browse the repository at this point in the history
* feat: migrate config to application

* !fixup

* !fixup

* !fixup

* Revert "!fixup"

This reverts commit 15088c6bd5269de8a8081ba3bd76a99b51b1ad3a.

* fix: use `getenv` instead of `$_ENV`

* fix: fix production environment identifiers

* fix: fix local config undefined index

* fix: add timeout to AWS calls in config

* chore: apply PHPCS
  • Loading branch information
JoshuaLicense authored Mar 11, 2024
1 parent d6f2acc commit 99a2ee8
Show file tree
Hide file tree
Showing 6 changed files with 921 additions and 553 deletions.
1 change: 1 addition & 0 deletions app/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data/db/live-like-data.sql
data/db/test-olcs-refdata.sql
test/coverage/
.scannerwork/
config/development.config.php
vendor-bin/**/composer.lock
.phpunit.result.cache

Expand Down
3 changes: 3 additions & 0 deletions app/api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"php": "^7.4",
"ext-intl": "*",
"ext-json": "*",
"ext-curl": "*",
"ext-redis": "*",
"ext-pdo": "*",
"aws/aws-sdk-php": "^3.183",
"beberlei/doctrineextensions": "^1.0",
"caseyamcl/guzzle_retry_middleware": "^2.7.1",
Expand Down
10 changes: 5 additions & 5 deletions app/api/config/application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@
// modules are loaded. These effectively override configuration
// provided by modules themselves. Paths may use GLOB_BRACE notation.
'config_glob_paths' => array(
__DIR__ . '/autoload/{,*.}{global,local}.php',
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
),

// Whether or not to enable a configuration cache.
// If enabled, the merged configuration will be cached and used in
// subsequent requests.
//'config_cache_enabled' => true,
'config_cache_enabled' => true,

// The key used to create the configuration cache file name.
//'config_cache_key' => $stringKey,
'config_cache_key' => 'application.config.cache',

// Whether or not to enable a module class map cache.
// If enabled, creates a module class map cache which will be used
// by in future requests, to reduce the autoloading process.
//'module_map_cache_enabled' => true,
'module_map_cache_enabled' => true,

// The key used to create the class map cache file name.
//'module_map_cache_key' => $stringKey,

// The path in which to cache merged configuration.
//'cache_dir' => __DIR__ . '/../data/cache/',
'cache_dir' => 'data/cache/',

// Whether or not to enable modules dependency checking.
// Enabled by default, prevents usage of modules that depend on other modules
Expand Down
33 changes: 33 additions & 0 deletions app/api/config/autoload/config-parameters.global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Dvsa\LaminasConfigCloudParameters\ParameterProvider\Aws\SecretsManager;
use Dvsa\LaminasConfigCloudParameters\ParameterProvider\Aws\ParameterStore;

$environment = getenv('ENVIRONMENT_NAME');

$providers = [];

if (!empty($environment)) {
$providers = [
SecretsManager::class => [
sprintf('DEVAPP%s-BASE-SM-APPLICATION-API', strtoupper($environment)),
],
ParameterStore::class => [
sprintf('/applicationparams/%s/', strtolower($environment)),
],
];
}

return [
'aws' => [
'global' => [
'http' => [
'connect_timeout' => 5,
'timeout' => 5,
],
],
],
'config_parameters' => [
'providers' => $providers,
],
];
Loading

0 comments on commit 99a2ee8

Please sign in to comment.