Download the PHP package arrilot/dotenv-php without Composer

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

Latest Stable Version Total Downloads Build Status Scrutinizer Quality Score

Simple dotenv for PHP

Introduction

Q: What's the point of this package? How is it any different from those vlucas/phpdotenv and josegonzalez/php-dotenv well-known packages?

A: Those great packages are NOT for production. They were always meant to be used during local development only. The main reasons are: 1) Not fast enough 2) Not secure enough

Many people are actually misuse those packages and use them to configure apps in production too.

In contrast this package IS for production. It uses plain old php array for .env content and doesn't touch $_ENV or $_SERVER by default. As a result it's fast and secure but has less features.

Installation

1) composer require arrilot/dotenv-php

2) Create .env.php file to store configuration settings that are environment specific or sensitive.

Example:

This file should NEVER be added to version control.

3) Create .env.example.php file and add it to version control. This file should serve as an example for developers how .env.php file should look like.

4) Load .env.php file

Usage

Getting data

The most used case is to get dotenv variable.

You may pass a second parameter, which is gonna be used as default if variable is not set.

Note This is the method you are going to use most of the time. It makes sense to add a global helper for it to avoid importing the class name and e.t.c.

You can also get all dotenv variables at once:

Setting data

You can set or override specific variable like that:

You can reload all variables entirely from file or array

Other methods

There is way to ensure that a specific dotenv variable exists. Example:

If the variable is not loaded an Arrilot\DotEnv\Exceptions\MissingVariableException will be thrown.

There are also convenient methods to copy all variables to putenv(), $_ENV or $_SERVER if you DO need it, but in most cases you don't

Testing

Q: Why are there so many static calls? How am I supposed to mock them in tests?

A: You shouldn't mock DotEnv class. Just override what you need using set or load methods. Note that load method understands arrays too.


All versions of dotenv-php with dependencies

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

Loading the files please wait ....