Download the PHP package gullevek/dotenv without Composer

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

dotenv: readEnvFile()

A simple implementation of https://github.com/vlucas/phpdotenv

This is not a functional replacement, but a very simple implementation of the basic functions.

It is recommended to create a .env.example example file that is checked into the repository. The .env should NEVER be checked into anything

How to install

composer require gullevek/dotEnv

Run it

Create a .env file in the current folder. Create a file like below

All data will be in the $_ENV array. Note that existing $_ENV data is never overwritten. If this is needed make a copy fo the $_ENV file and reset it, or if the data is not needed just reset it.

SUCCESS with problem errors can be read from DotEnv::getLastReadEnvFileErrors()

readEnvFile: Options

read outside environment data

Normal environment data is not loaded into the $_ENV variable. If this is needed this can be done with \gullevek\dotEnv\DotEnv::loadOutsideGetEnv()

loadOutsideGetEnv: Options

Note to env_list, entries can be fnmatch notated

The wildcard style does not support matching with "*" in the middle

How it works

Put the function where it is needed or put it in a file and load it.

if not parameter is given it will use __DIR__ as base path. Second parameter is file name override. Default is .env

Data is loaded into _ENV only.

If there is already an entry in _ENV then it will not be overwritten.

Errors

The readEnvFile will return a DotEnvLevel status message

Reading SUCESS_* status block errors

If we have anything other than plain SUCCESS we can check the keys that had errors with DotEnv::getLastReadEnvFileErrors(). The returned array key is the DotEnvLevel name as string and has a list of all loaded keys that fall into this error.

Example:

Exceptions

Optional the method can be set to throw exceptions for file reading issuses by setting "throw_exceptions" to true

.env file example

A valid entry has to start with an alphanumeric string, underscores are allowed and then have an equal sign (=). After the equal sign the data block starts. Data can be quoted with double quotes (") and if this is done can stretch over multiple lines. The openeing double quote must be on the same lign as the requal sign (=). If double quoted (") charcters are used it will read each line until another double quote (") character is found. Everything after that is ignored.

Any spaces before the variable or before and after the equal sign (=) are ignored.

Line is read until PHP_EOL. So any trailing spaces are read too.

Any line that is not valid is ignored.

A prefix name can be set with [PrefixName]. Tne name rules are like for variables, but spaces are allowed, but will be converted to "_". The prefix is valid from the time set until the next prefix block appears or the file ends.

Example

Will have environmen variables as

Development

Phan

vendor/bin/phan --analyze-twice

PHPstan

vendor/bin/phpstan

PHPUnit

Unit tests have to be run from base folder with

vendor/bin/phpunit


All versions of dotenv with dependencies

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

Loading the files please wait ...