0

In an Apigility driven Zend Framework 2 application wenn a database adapter is created (over the Apigility Admin UI), its settings by default get saved in /config/autoload/global.php

return array(
    'db' => array(
        'adapters' => array(
            ...
            'DbAdapter_FooBar' => array(),
            ...
        ),
    ),
    ...
);

and in /config/autoload/local.php

return array(
    'db' => array(
        'adapters' => array(
            ...
            'DbAdapter_FooBar' => array(
                'charset' => 'UTF-8',
                'database' => 'asdf',
                'driver' => 'PDO_Mysql',
                'hostname' => 'asdf',
                'username' => 'asdf',
                'password' => 'asdf',
                'port' => '1234',
                'driver_options' => array(
                    1002 => 'SET NAMES \'UTF8\'',
                ),
            ),
            ...
        ),
    ),
    ...
);

In the application I'm working on the config files structure differs from the ZF2 standard, e.g. there are separate config files for the database settings: /config/autoload/mydb.global.php and /config/autoload/mydb.local.php.

(How) Can Apigility be configured in the way, that the database adapters settings get stored in custom config files? How/where to set these files?

automatix
  • 14,018
  • 26
  • 105
  • 230

1 Answers1

0

Configuration for various components can be provided in multiple places, but all configuration is merged recursively into one large configuration file by the Zend\Stdlib\ArrayUtils::merge() method. Because configurations are merged recursively, the order that they are added to the merged configuration array is really important to avoid unexpected overwriting.

Configurations are merged in the following order:

  • The array returned by the module’s getConfig() method
  • config/autoload/*.global.php — global autoload files
  • config/autoload/*.local.php — local autoload files
  • The methods described by the Feature interface — get*Config()
Dolly Aswin
  • 2,684
  • 1
  • 20
  • 23