1. Go to this page and download the library: Download threatdatascience/envarray library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
threatdatascience / envarray example snippets
/**
* Given the following environmental vars:
*
* DB_HOST=mysql.myhost.com
* DB_USER=webmaster
* DB_PASS=weakpassword
*/
$envArray = new \ThreatDataScience\EnvArray\EnvArray();
$array = [
'database' => [
'host' => '{{DB_HOST:string:127.0.0.1}}',
'port' => '{{DB_PORT:int:3306}}',
'user' => '{{DB_USER:string:root}}',
'password' => '{{DB_PASS:string:root}}'
]
];
$array = $envArray->fill($array);
/**
* Will give you:
*
* [
* 'database' => [
* 'host' => 'mysql.myhost.com',
* 'port' => 3306,
* 'user' => 'webmaster',
* 'password' => 'weakpassword'
* ]
* ];
*/
/**
* It works with flat arrays too!
*
* (Note, we don't condone this specific use case example, use a load balancer)
*
* Given the following environmental vars:
*
* ELASTIC_01=01.es.myhost.com
* ELASTIC_01=02.es.myhost.com
* ELASTIC_03=03.es.myhost.com
*/
$envArray = new \ThreatDataScience\EnvArray\EnvArray();
$array = [
'elastic' => [
'{{ELASTIC_01}}',
'{{ELASTIC_02}}',
'{{ELASTIC_03}}'
]
];
$array = $envArray->fill($array);
/**
* Will give you:
*
* [
* 'elastic' => [
* '01.es.myhost.com',
* '02.es.myhost.com',
* '03.es.myhost.com',
* ]
* ];
*/
text
{{DB_HOST:int:789.0909}}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.