1. Go to this page and download the library: Download cekurte/environment 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/ */
cekurte / environment example snippets
use function Cekurte\Environment\env; // To get values using a function ( Cekurte\Environment\EnvironmentVariable; // To get values using a object
// ...
$data = Environment::get("YOUR_ENVIRONMENT_KEY");
// Getting default data if your environment variable not exists or not is loaded.
$data = Environment::get("APP_DEBUG", true);
// ...
// Other ways to get the values of environment variables.
// Using a object...
$data = (new EnvironmentVariable())->get("YOUR_ENVIRONMENT_KEY", "defaultValue");
// Using a function... @deprecated
$data = env("YOUR_ENVIRONMENT_KEY", "defaultValue");
// Note that if the second parameter is omitted
// then the return value (if your key not exists) will be null.
// A new way was added to you get all environment variables as an array.
$data = Environment::getAll();
// You can use a filter to get only the environment variables that you need.
$data = Environment::getAll([
new Cekurte\Environment\Filter\KeyRegexFilter('/PROCESSOR/'),
new Cekurte\Environment\Filter\ValueRegexFilter('/6/'),
]);
// The method above will get all environment variables, where:
// the environment variable name has the word PROCESSOR AND
// the environment variable value has the number six.
// And you can develop your own filters, contribute with this project!