1. Go to this page and download the library: Download didslm/env 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/ */
didslm / env example snippets
class Config
{
#[EnvObj]
public DbConfig $mysqlConfig;
}
class DbConfig
{
#[EnvName('DB_HOST')]
public string $dbHost;
#[EnvName('DB_USER')]
public string $username;
#[EnvName('DB_PASSWORD')]
public string $password;
#[EnvName('DB_DATABASE')]
public string $database;
}
$config = new DbConfig();
//The next line will populate the class properties with the env variables if they exist.
Env::populate($config);
$allConfig = new Config();
Env::populate($allConfig);
class Defaults
{
#[EnvName('APP_REGION', default: 'eu-west-1')]
public string $region;
}
class Services
{
#[EnvObj(ServiceConfig::class)]
public ServiceConfig $billing;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.