PHP code example of devcirclede / env-reader
1. Go to this page and download the library: Download devcirclede/env-reader 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 / env-reader example snippets
declare(strict_types=1);
namespace Company\EnvTypes;
use DevCircleDe\EnvReader\Types\TypeInterface;
class CustomType implements TypeInterface
{
public function getName(): string
{
return 'custom';
}
public function convert(string $value): mixed
{
// convert the value to custom type
return $value;
}
}
use Company\EnvTypes\CustomType;
use DevCircleDe\EnvReader\EnvParser;
$envParser = EnvParser::getInstance();
// add custom type
$envParser->getCollection()->addItem(new CustomType());
// read Env
$var = $envParser->parse('FOO', 'custom_type');