Our new approach to defining DB connection settings is to put them in Configure and have DATABASE_CONFIG::__construct() extract them into class properties. This has the side effect of breaking the db-credentials and db-backup "shell" scripts (which are actually implemented in PHP) since they both try to include('Config/database.php') in order to extract the connection values from the ::$default property.
This no longer works in a command line context because the DATABASE_CONFIG class now depends on the Configure class and a host of other associated Cake core libs. These classes are not available without the Cake bootstrapping process, so it's no longer possible to directly instantiate DATABASE_CONFIG. There are two alternatives:
- Define our own very crude Configure class that has no other dependencies and use it to extract the values we need from
Config/core.php.
- Detect the presence of the
Loadsys/ConfigReadShell plugin, and use bin/cake config_read.config_read Database.default to obtain the DB connection values we need. (This approach has already been implemented in the EducationUnlimited legacy app, which has its own static copies of db-credentials and db-backup.)
Ideally, both approaches should be used so that the db-* scripts remain as versatile and "unspecialized" as possible.
Our new approach to defining DB connection settings is to put them in
Configureand haveDATABASE_CONFIG::__construct()extract them into class properties. This has the side effect of breaking thedb-credentialsanddb-backup"shell" scripts (which are actually implemented in PHP) since they both try toinclude('Config/database.php')in order to extract the connection values from the::$defaultproperty.This no longer works in a command line context because the
DATABASE_CONFIGclass now depends on theConfigureclass and a host of other associated Cake core libs. These classes are not available without the Cake bootstrapping process, so it's no longer possible to directly instantiateDATABASE_CONFIG. There are two alternatives:Config/core.php.Loadsys/ConfigReadShellplugin, and usebin/cake config_read.config_read Database.defaultto obtain the DB connection values we need. (This approach has already been implemented in the EducationUnlimited legacy app, which has its own static copies of db-credentials and db-backup.)Ideally, both approaches should be used so that the db-* scripts remain as versatile and "unspecialized" as possible.