Thanks again to @darkalchemy for the solution.
I tried to implement selective/config, and, for today, it works in my Slim 4 project. Especially, “Injecting the configuration” is very convenient.
In my project, base url of some image is concatenated with image’s name. These images’ names are written in MySQL DB.
So, to get images’ names and base url together in server response.
-
phpdotenv (it’s not work):
$baseUrlImg = getenv(‘BASE_URL_IMAGE’);
$sql = “SELECT id, CONCAT (’$baseUrlImg’,‘product_img_dir/’, img) AS img, name FROM products”; -
selective/config (it works)
$baseUrlImg = $this->config->getString(‘base_url.base_url_img’);
$sql = “SELECT id, CONCAT (’$baseUrlImg’,‘product_img_dir/’, img) AS img, name FROM products”;
Sorry, but I still to wonder. Is it safe enough to keep sensitive credentials in settings.php of Slim 4 project?
Thanks in advance.