external config file for homepresenter

kolaloka
Member | 69
+
0
-

I need to create an external config file where a web admin can change some variables. I do not know how to set the /path/to/my/config/

Also where to put it and how to use the variables in presenter functions?
My idea is something like this:

config.php:

<?php
$ds = something;
$identity1 = something_else;
$identity2 = something_else;
$password = secretpassword;
?>

HomePresenter.php:

<?php
...
include /path/to/my/config/config.php

private function connectionOne{
$bind = ldap_bind($ds, $identity1, $password);
}

private function connectionTwo{
$bind = ldap_bind($ds, $identity2, $password);
}
...
?>

Please, help.

CZechBoY
Member | 3608
+
0
-

You can save these variables into database and fetch them when needed.

kolaloka
Member | 69
+
+1
-

Unfortunately not. They want a plain file to be able to configure themselves. Can nette do that?

CZechBoY
Member | 3608
+
+1
-

OK, then you can use neon file, or php script or other format…
Only thing you should do is to load that configuration file(s) in bootstrap.php [https://doc.nette.org/…on/bootstrap#…]
like this

$configurator->addConfig('config.neon');

And put there some parameters
like this

parameters:
	ldap:
		user: xxx
		password: yyy
		host: abc

For more info read the whole DIC page https://doc.nette.org/…introduction

Last edited by CZechBoY (2018-06-04 10:27)

kolaloka
Member | 69
+
0
-

OK, I understand now. Thank you very much!