Download the PHP package phpdot/env without Composer

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

phpdot/env

Typed, schema-validated, immutable .env configuration for modern PHP.

Install

Zero dependencies. Pure PHP 8.3+.

Quick Start

Two access patterns are supported — pick whichever fits your bootstrap.

Instance-based

Global facade (recommended for app bootstrap)

Env::init() is a thin wrapper over safeCreate() — missing .env files are silently skipped, schema defaults are used. The global env() helper reads from the singleton.

Every value is typed. Every key is validated. Every access is a pure array lookup.


Architecture


Schema

The schema is the source of truth. Every env var must be declared.

Type System

Type PHP return Example
STRING string APP_NAME=MyApp"MyApp"
INT int PORT=80808080
FLOAT float RATE=1.51.5
BOOL bool DEBUG=truetrue
ENUM BackedEnum ENV=productionAppEnv::PRODUCTION
LIST list<string> IPS=a,b,c["a","b","c"]
JSON mixed CFG={"a":1}["a" => 1]

Bool recognizes (case-insensitive): true/false, 1/0, yes/no, on/off.

Constraints

Constraint Applies to Example
required All Key must exist or have default
not_empty All '' after trim fails
min INT, FLOAT 'min' => 1
max INT, FLOAT 'max' => 65535
allowed STRING 'allowed' => ['debug', 'info']
pattern STRING 'pattern' => '/^https?:\/\//'
sensitive All Masked in allMasked()

Multi-File Loading

Files load in order. Later files override earlier ones.

Cross-file interpolation works:


.env Syntax

Values

Escapes (double-quoted only)

Comments

Multiline

Interpolation

Export Prefix


Safe Loading

For Docker/k8s where .env may not exist:

Missing files are silently skipped. Schema defaults are used.


Testing


Instance API

Beyond get(), the Env instance exposes:

Method Returns Purpose
$env->get($key) mixed (typed) Throws SchemaException on unknown key
$env->has($key) bool True if explicitly set in a .env file (not just defaulted)
$env->all() array<string, mixed> All typed values, including defaults
$env->allMasked() array<string, mixed> Same, but sensitive keys replaced with ***
$env->getRaw($key) string\|null Raw string before type cast
$env->getSchema() EnvSchema The compiled schema
$env->getLoadedFiles() list<string> Paths of .env files actually parsed
$env->compile($path) void Write a cache file for fast worker boot

The static facade exposes a parallel surface: Env::env($key, $default), Env::getInstance(), Env::resetInstance() (testing).


Sensitive Values

allMasked() is safe for logging and error reports.


Config Caching

For production — skip parsing on every worker boot:

Opcache caches the compiled file. Zero disk I/O, zero parsing per worker.


EnvEditor (CLI Only)

Write tool for setup wizards and deployment scripts.

Preserves comments, blank lines, and key order.


Parsing a String


Swoole Safety

Env is immutable. readonly arrays. Zero mutation methods. Two safe patterns:


Package Structure


Development

License

MIT


All versions of env with dependencies

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

Loading the files please wait ...