Correct way to add a file to config/


#1

I am looking to add a file merchants.php which will contain all my merchant config info, api key, etc…

What is the correct way to go about getting that file included?


#2

Put the file int your /config folder and define a $config array in the file, than load it in your /config/bootstrap.php.
Configure::load('merchants', 'default', false);


#3

Thank you very much! =]


#4

Follow up question…

Im not in a place where I can test just yet, I am awaiting a reset of sandbox credentials…

when I have my array like

return [
    'Merchants' => [
        'MERCHANT_LOGIN_ID' => '',
        'MERCHANT_TRANSACTION_KEY' => '',
        'MERCHANT_SANDBOX' => true
    ]
];

Do I read it like so?

 Configure::read('Merchants.MERCHANT_LOGIN_ID')

#5

Found it!

https://book.cakephp.org/3.0/en/development/configuration.html

Thank you again!