Download the PHP package laxity7/dotenv without Composer

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

Simply PHP dotenv

Simply Dotenv parser .env files to make environment variables stored in them accessible via getenv(), $_ENV and Env::get().

License Latest Stable Version Total Downloads

The class allows working with local variables from .env, as with global environment variables

Install

Install via composer

How to use

The .env file is generally kept out of version control since it can contain sensitive API keys and passwords. A separate .env.example file is created with all the required environment variables defined except for the sensitive ones, which are either user-supplied for their own development environments or are communicated elsewhere to project collaborators. The project collaborators then independently copy the .env.example file to a local .env and ensure all the settings are correct for their local environment, filling in the secret keys or providing their own values when necessary. In this usage, the .env file should be added to the project's .gitignore file so that it will never be committed by collaborators. This usage ensures that no sensitive passwords or API keys will ever be in the version control history so there is less risk of a security breach, and production values will never have to be shared with all project collaborators.

Add your application configuration to a .env file in the root of your project or other place.

Make sure the .env file is added to your .gitignore so it is not checked-in the code.

See all possible use cases in the file "tests/test.env".

Ok, after creating the .env file, you can then load .env in your application.

Basic usage:

There will be no error if the file .env does not exist, only global variables will be taken

Now all the defined variables are available in the $_ENV and $_SERVER super-globals.

If your $_ENV array is mysteriously empty, but you still see the variables when calling getenv() or in your phpinfo(), check your http://us.php.net/manual/en/ini.core.php#ini.variables-order ini setting to ensure it includes "E" in the string.

To get values through the getenv() function use the usePutEnv parameter (but not recommended).

You can also use the get method, which can return a default value (default null) if a key is missing.

For simplicity, you can create an env helper function

or use helper class Env

or combine both methods

How is this better than symfony/dotenv package?

Firstly, this package is natively support boolean values.

For example,

Secondly, this package is significantly faster than symfony/dotenv, with tests showing it to be up to ~4 times quicker in certain scenarios. This can be a major advantage for projects where performance is critical and every millisecond count.

# Laxity7 Symfony
min 0.0218 ms 0.0773 ms
max 0.3831 ms 0.9657 ms
avg 0.0238 ms 0.0967 ms

You can run the tests yourself by running the following command:

Thirdly, this package has built-in error smoothing, which allows you to skip common formatting errors (for example, spaces, lack of an equal sign and others) found in .env files. This makes it more user-friendly than symfony/dotenv, which requires you to write the .env file exclusively correctly.

For example, this .env file will be loaded without errors in laxity7/dotenv

But Symfony/dotenv will throw the following exceptions:

Fourth, this package provides inline comments in .env iles.

In summary, this package is a faster and more user-friendly option for managing environment variables on your project compared to symfony/dotenv. While it may not have the same level of community support or features as its competitor, its focus on performance and ease of use may make it an attractive choice for many developers.


All versions of dotenv with dependencies

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

Loading the files please wait ....