Download the PHP package quillstack/dotenv without Composer

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

Quillstack Dotenv

Tests Latest Version Downloads PHP Version StyleCI CodeFactor Quality Gate Coverage Maintainability Reliability Security License

Reads a .env file into the environment. Values keep their types, and anything it cannot finish reading it refuses rather than guessing at.

Why this exists

It does not expand ${SOMETHING}, and that is on purpose

Most PHP .env libraries resolve one value from another out of the box. This one does not, and the model it follows is JavaScript's.

dotenv for Node is the most installed .env library anywhere, and it does not interpolate. Nor does dotenv-java. In that world, building values from other values is a second package — dotenv-expand — because it is a second decision: it turns a list of pairs into a small language, with escaping and ordering and undefined names to settle. Here that package is quillstack/dotenv-expand.

Running the same file through eight implementations across six languages, this is where they stand:

Language Library Expands ${…}
JavaScript dotenv no — dotenv-expand does
Java dotenv-java no
PHP quillstack/dotenv no — quillstack/dotenv-expand does
PHP symfony/dotenv yes
PHP vlucas/phpdotenv yes
PHP josegonzalez/dotenv yes
Python python-dotenv yes
Ruby dotenv yes
Dart dotenv yes
C dotenv-c yes

The part JavaScript does not do

Node's dotenv leaves URL=${BASE}/v1 as the literal text ${BASE}/v1, and hands it over without comment. An application then holds a string that looks like an address and is not one.

This refuses instead:

Which is what makes leaving the second package out safe rather than merely cheap. Nothing is quietly half-read, in either configuration.

The same care everywhere else

A # after a value is a comment, an export prefix is understood, and hunter2#7 is still a password — the details a file written for a shell gets right and a naive parser does not. Each of those was a wrong value handed over without a word until it was fixed.

Requirements

Installation

Usage

Values keep the type they plainly have, so if (env('APP_DEBUG')) means what it reads as.

Default values

Required keys

Where there is no sensible default, say so and find out at boot rather than at midnight:

Comments after a value

A # starts a comment where a shell would treat it as one — after whitespace, and outside quotes:

The export keyword

The same file read by source is written with export, and it is understood here too:

Multi-line values

Write \n rather than a real line break:

Values built from other values

Refused, as above. Install quillstack/dotenv-expand and it resolves. Where a ${ means only itself, escape it:

Reading a file without loading it

parse() hands back what the file holds and touches nothing:

References are left exactly as written, escapes included — which is what lets quillstack/dotenv-expand tell ${BASE} from \${BASE}.

Benchmark

Measured with quillstack/benchmark on one file of 34 keys with no interpolation in it, which all five read identically. Runs are interleaved, each figure is the median of five, and PHP is 8.5.7.

Version
quillstack/dotenv v0.7.1
quillstack/dotenv-expand v0.6.1
symfony/dotenv v7.4.15
josegonzalez/dotenv 4.0.0 (on m1/env 2.2.0)
vlucas/phpdotenv v5.6.4

Reading that file, once:

Per load Relative Files loaded Memory
quillstack/dotenv 146 µs 5 70 kB
quillstack/dotenv + dotenv-expand 176 µs 1.20× 6 87 kB
symfony/dotenv 233 µs 1.60× 1 149 kB
josegonzalez/dotenv 301 µs 2.06× 7 153 kB
vlucas/phpdotenv 479 µs 3.27× 34 336 kB

The second row is this package with quillstack/dotenv-expand on top: adding it costs about a fifth of the reading time, and it is still the fastest way in this table to resolve a .env at all. That package's README has the same comparison on a file which does use ${…} — one this package refuses outright, so it has no row there.

The files-loaded column is where the cold-start difference comes from: vlucas/phpdotenv reads 34 files and four packages into memory before parsing anything. Starting a process and loading those dominates the first read by an order of magnitude more than parsing does, which is why the per-load figure above is measured warm — it is the part this package controls.

What the numbers do not say: the other three expand ${…} and this one does not, and symfony/dotenv also reads .env.local layering and shell command substitution. Being faster because you do less is not being faster; the row above with dotenv-expand added is the like-for -like one.

Tests

The rest of Quillstack

This is one component of Quillstack, a PHP framework which is as simple to use as it is strict about what it does.

License

MIT — see LICENSE.


All versions of dotenv with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
quillstack/local-storage Version ^0.6
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 quillstack/dotenv contains the following files

Loading the files please wait ...