Download the PHP package initphp/dotenv without Composer

On this page you can find all versions of the php package initphp/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

InitPHP DotENV

Loads environment variables from a .env or .env.php file into PHP's environment ($_ENV, $_SERVER, getenv()), with type coercion and ${VAR} interpolation.

CI Latest Stable Version Total Downloads License PHP Version Require

Requirements

Installation

Quick start

/home/www/.env:

Prefer an isolated instance (e.g. for DI or tests)? Use the Repository directly:

File format in brief

Full details: docs/.

API summary

Call Returns Purpose
DotENV::create(string $path, bool $debug = true) void Load a .env/.env.php file or a directory containing one.
DotENV::get(string $name, mixed $default = null) mixed Read a value ($_ENV$_SERVERgetenv()).
DotENV::env(string $name, mixed $default = null) mixed Alias of get().
DotENV::flush() void Unload everything this instance defined.
DotENV::reset() void flush() and drop the shared instance.
DotENV::drift(string\|array $reference, array $options = []) DriftReport Compare the loaded env against a reference and report drift.
DotENV::assertNoDrift(string\|array $reference, array $options = []) void Strict mode: throw DriftException when drift is found.
env(string $name, mixed $default = null) mixed Global helper for DotENV::get().
env_drift(string\|array $reference, array $options = []) DriftReport Global helper for DotENV::drift().

See the API reference for details.

Env drift

Once an env file is loaded you can check it for drift against a reference — the keys that should be present. It catches the failure that bites in CI/production: a key your code expects that was never provisioned.

The reference can be a .env.example path (the usual convention) or a required-keys array:

Drift is grouped into three buckets:

Bucket Meaning Default
missing a reference key absent from the actual environment always reported
extra a key this loader defined that is not in the reference opt-in (['extra' => true])
empty a reference key that is present but blank opt-in (['empty' => true])

extra and empty are off by default: extra keys are usually noise, and only keys this loader defined are ever considered for extra (unrelated OS variables are never reported).

Strict mode (CI gate)

assertNoDrift() runs the same comparison and throws a DriftException the moment any drift is found — drop it into a bootstrap or a CI check to fail fast:

DriftException extends DotENVException (and InvalidArgumentException), so existing catch blocks keep working, and the offending DriftReport is attached via getReport().

Drift checking is read-only: it never defines, reads-through, or mutates any environment value, so it is safe to run after create() without changing what is loaded. See docs/env-drift.md for the full reference.

Notes

Upgrading from 2.x

3.0 is a maintenance-focused major release. The public API (DotENV::create, get, env and the env() helper) is unchanged, but note:

See the changelog for the full list.

Contributing

Bug reports and pull requests are welcome. The CI runs PHP-CS-Fixer, PHPStan (max level) and PHPUnit across PHP 8.0–8.4; run the same bundle locally with:

Credits

License

Copyright © 2022 InitPHP — released under the MIT License.


All versions of dotenv with dependencies

PHP Build Version
Package Version
Requires php Version >=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 initphp/dotenv contains the following files

Loading the files please wait ...