Download the PHP package laxity7/dotenv without Composer

On this page you can find all versions of the php package laxity7/dotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dotenv

PHP DotEnv

A fast, lightweight .env file parser for PHP. Loads environment variables and makes them accessible via $_ENV, getenv(), and the built-in Env::get() helper.

License Latest Stable Version Total Downloads

Table of Contents

Requirements

Installation

Quick Start

Create a .env file in your project root (make sure it is added to .gitignore):

Load it in your application:

All loaded variables are also available in $_ENV:

If the file does not exist, no error is thrown — only already existing environment variables will be available.

You can load additional files. By default, existing variables are not overwritten:

Helper Function

For convenience, you can create a global env() helper:

Or use the built-in Env static helper:

Or combine both approaches for a short env() function:

Features

Type Casting

Values are automatically cast to native PHP types:

.env value PHP type PHP value
FOO=hello string 'hello'
FOO=123 int 123
FOO=3.14 float 3.14
FOO=.5 float 0.5
FOO=true / FOO=false bool true/false
FOO=null null null
FOO= null null
FOO="true" string 'true'
FOO="123" string '123'

Note: Quoted values ("..." or '...') are always treated as strings, even if they look like numbers or booleans.

Variable Interpolation

Reference previously defined variables using ${VAR} syntax:

Interpolation is not performed inside single-quoted values: FOO='${BAR}' will remain the literal string ${BAR}.
If a referenced variable is not defined, it is replaced with an empty string.

Export Prefix

Lines prefixed with export are supported (common in shell-compatible .env files):

The export keyword is simply stripped — variables are loaded as usual.

Inline Comments

Comments are supported both on their own line and inline:

Error Tolerance

Unlike many parsers, this package gracefully handles common formatting issues:

All of the above will be parsed without errors.

API

DotEnv

load(string $path, bool $overrideExistingVars = false, bool $usePutEnv = false): void

Load variables from a .env file.

get(string $name, $default = null): mixed

Get the value of an environment variable. Returns $default if the variable is not defined.

has(string $name): bool

Check whether a variable exists (including variables with a null value).

getAll(): array

Return all loaded environment variables as an associative array.

clear(): void

Clear the internal variable store. Does not modify $_ENV or system environment — only resets the internal state.

$usePutEnv (property)

When enabled, variables are also registered via putenv(), making them accessible through getenv().

⚠️ putenv() is not thread-safe. Use only when you specifically need getenv() support.

The $usePutEnv parameter in load() serves the same purpose but applies only to that single call, while the property applies to all subsequent load() calls.

Env Helper

A static helper class for convenient access from anywhere in your application.

Calling get() or has() before load() will throw a \RuntimeException.

Comparison with symfony/dotenv

Feature laxity7/dotenv symfony/dotenv
Native boolean casting
Native int/float casting
Error tolerance
Inline comments
Variable interpolation
export prefix
Performance ~4× faster baseline

Boolean Values

Performance

Benchmark results (10 000 iterations):

Metric laxity7/dotenv symfony/dotenv
min 0.0218 ms 0.0773 ms
max 0.3831 ms 0.9657 ms
avg 0.0238 ms 0.0967 ms

Run benchmarks yourself:

Error Tolerance

This .env file is valid for laxity7/dotenv, but causes exceptions in symfony/dotenv:

symfony/dotenv errors:

Development

The project uses Docker for all commands, so no local PHP installation is required.

License

MIT


All versions of dotenv with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4|>=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laxity7/dotenv contains the following files

Loading the files please wait ...