I don't want to store my password for my database configuration in plain text in the database.php for revision control reasons.
I want something like this:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => simpleEncryptFunction('v3RyH4rD3NcRyPtEdPaS$wOrD'),
'database' => 'sample',
'prefix' => '',
//'encoding' => 'utf8',
);
private function simpleEncryptFunction($hardPassword == null) {
// Some pretty easy decrypt code. Not safe at all but I don't care.
// It just shouldn't be that easy for people who don't understand code.
}
ndm's comment is right, your approach is flawed. Instead do this:
database.default.php
and put the default values in it without passwords and commit it.database.php
in your .gitignore
, this file should never going to be committed.database.default.php
to default.php
and replace the password value with whatever is neededThe same concept can be applied to bootstrap.php
as well. And check this plugin out, we're using it for a project to have multiple environments configured and loaded conditionally.