Env
class Env (View source)
Properties
static protected bool | $putenv | Indicates if the putenv adapter is enabled. |
|
static protected RepositoryInterface|null | $repository | The environment repository instance. |
|
static protected Closure[] | $customAdapters | The list of custom adapters for loading environment variables. |
Methods
Enable the putenv adapter.
Disable the putenv adapter.
Get the environment repository instance.
Get the value of an environment variable.
Get the value of a required environment variable.
Write an array of key-value pairs to the environment file.
Write a single key-value pair to the environment file.
Add a variable to the environment file contents.
Get the possible option for this environment variable.
Wrap a string in quotes, choosing double or single quotes.
Escape a string using addslashes, excluding the specified characters from being escaped.
Details
static void
enablePutenv()
Enable the putenv adapter.
static void
disablePutenv()
Disable the putenv adapter.
static void
extend(Closure $callback, string|null $name = null)
Register a custom adapter creator Closure.
static RepositoryInterface
getRepository()
Get the environment repository instance.
static mixed
get(string $key, mixed $default = null)
Get the value of an environment variable.
static mixed
getOrFail(string $key)
Get the value of a required environment variable.
static void
writeVariables(array $variables, string $pathToFile, bool $overwrite = false)
Write an array of key-value pairs to the environment file.
static void
writeVariable(string $key, mixed $value, string $pathToFile, bool $overwrite = false)
Write a single key-value pair to the environment file.
static protected array
addVariableToEnvContents(string $key, mixed $value, array $envLines, bool $overwrite)
Add a variable to the environment file contents.
static protected Option|Some
getOption(string $key)
Get the possible option for this environment variable.
static protected string
prepareQuotedValue(string $input)
Wrap a string in quotes, choosing double or single quotes.
static protected string
addSlashesExceptFor(string $value, array $except = [])
Escape a string using addslashes, excluding the specified characters from being escaped.