Dotenv
in package
Table of Contents
Properties
- $loader : LoaderInterface
- The loader instance.
- $parser : ParserInterface
- The parser instance.
- $repository : RepositoryInterface
- The repository instance.
- $store : StoreInterface
- The store instance.
Methods
- __construct() : void
- Create a new dotenv instance.
- create() : Dotenv
- Create a new dotenv instance.
- createArrayBacked() : Dotenv
- Create a new dotenv instance with an array backed repository.
- createImmutable() : Dotenv
- Create a new immutable dotenv instance with default repository.
- createMutable() : Dotenv
- Create a new mutable dotenv instance with default repository.
- createUnsafeImmutable() : Dotenv
- Create a new immutable dotenv instance with default repository with the putenv adapter.
- createUnsafeMutable() : Dotenv
- Create a new mutable dotenv instance with default repository with the putenv adapter.
- ifPresent() : Validator
- Returns a new validator object that won't check if the specified variables exist.
- load() : array<string, string|null>
- Read and load environment file(s).
- parse() : array<string, string|null>
- Parse the given content and resolve nested variables.
- required() : Validator
- Required ensures that the specified variables exist, and returns a new validator object.
- safeLoad() : array<string, string|null>
- Read and load environment file(s), silently failing if no files can be read.
Properties
$loader
The loader instance.
private
LoaderInterface
$loader
$parser
The parser instance.
private
ParserInterface
$parser
$repository
The repository instance.
private
RepositoryInterface
$repository
$store
The store instance.
private
StoreInterface
$store
Methods
__construct()
Create a new dotenv instance.
public
__construct(StoreInterface $store, ParserInterface $parser, LoaderInterface $loader, RepositoryInterface $repository) : void
Parameters
- $store : StoreInterface
- $parser : ParserInterface
- $loader : LoaderInterface
- $repository : RepositoryInterface
create()
Create a new dotenv instance.
public
static create(RepositoryInterface $repository, string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $repository : RepositoryInterface
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvcreateArrayBacked()
Create a new dotenv instance with an array backed repository.
public
static createArrayBacked(string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvcreateImmutable()
Create a new immutable dotenv instance with default repository.
public
static createImmutable(string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvcreateMutable()
Create a new mutable dotenv instance with default repository.
public
static createMutable(string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvcreateUnsafeImmutable()
Create a new immutable dotenv instance with default repository with the putenv adapter.
public
static createUnsafeImmutable(string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvcreateUnsafeMutable()
Create a new mutable dotenv instance with default repository with the putenv adapter.
public
static createUnsafeMutable(string|array<string|int, string> $paths[, string|array<string|int, string>|null $names = null ][, bool $shortCircuit = true ][, string|null $fileEncoding = null ]) : Dotenv
Parameters
- $paths : string|array<string|int, string>
- $names : string|array<string|int, string>|null = null
- $shortCircuit : bool = true
- $fileEncoding : string|null = null
Return values
DotenvifPresent()
Returns a new validator object that won't check if the specified variables exist.
public
ifPresent(string|array<string|int, string> $variables) : Validator
Parameters
- $variables : string|array<string|int, string>
Return values
Validatorload()
Read and load environment file(s).
public
load() : array<string, string|null>
Tags
Return values
array<string, string|null>parse()
Parse the given content and resolve nested variables.
public
static parse(string $content) : array<string, string|null>
This method behaves just like load(), only without mutating your actual environment. We do this by using an array backed repository.
Parameters
- $content : string
Tags
Return values
array<string, string|null>required()
Required ensures that the specified variables exist, and returns a new validator object.
public
required(string|array<string|int, string> $variables) : Validator
Parameters
- $variables : string|array<string|int, string>
Return values
ValidatorsafeLoad()
Read and load environment file(s), silently failing if no files can be read.
public
safeLoad() : array<string, string|null>