1. Go to this page and download the library: Download devcirclede/attrenv 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/ */
devcirclede / attrenv example snippets
use DevCircleDe\Attrenv\Attribute\EnvironmentValue;
use DevCircleDe\Attrenv\Attrenv;
class EnvConfiguredClass {
#[EnvironmentValue]
private string $secret;
#[EnvironmentValue(envName: 'ENV_NAME')]
private string $betterInternalName;
#[EnvironmentValue(type: 'json', default: ['simple' => 'better'])]
private array $configArrayJson;
public function __construct(
#[EnvironmentValue]
private readonly string $databaseName,
#[\SensitiveParameter]
#[EnvironmentValue]
string $secret,
private readonly array $optional = []
) {
}
}
$envConfiguredClass = (new Attrenv())->getParser()->parse(EnvConfiguredClass::class);
return [
'DevCircleDe\Attrenv\Decorator\EnvParserInterface' => new CustomParser(),
];
$envConfiguredClass = (new Attrenv('your/path/to/config.php'))->getParser()->parse(EnvConfiguredClass::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.