Download the PHP package helhum/dotenv-connector without Composer

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

dotenv connector Build Status

This is a composer plugin, that makes environment variables from a .env file available for any composer based project, without the need to modify code in the project.

Background info

You may want to read why it is a good idea to store config in the environment. The idea of dotenv is to make this as easy as possible and this is why the phpdotenv library was created. phpdotenv loads environment variables from an .env file to getenv(), $_ENV and $_SERVER, but you need to add the parsing code for that yourself.

composer + symfony/dotenv + dotenv connector = <3

The idea of this library is, that every composer managed project, a .env file (in the same location as your root composer.json) is automatically parsed and loaded, at composer autoload initialisation time. This means that the environment variables are available very early, so that you can use it also during boot time of your application.

If the environment variable APP_ENV is set to any value, or the specified .env file does not exist, no operation is performed, so that you can safely require this package for production.

If you have the possibility to expose environment variables in a production environment, it is recommended to do so and also set APP_ENV and use the variables that are directly exposed in the environment.

However for smaller scale projects it is still a valid and easy solution to use a .env file also for production environments.

configuration options

Usually you don't need any configuration options. However if you need to, you can adapt the path or name of the .env to fit your requirements.

You configure dotenv connector in the extra section of the root composer.json file like that:

env-file

You can specify a relative path from the base directory, if you want to put your .env file a different location.

The default value is ".env", which means next to your root composer.json.

Side note for quoting values in the .env file

As the .env file parsing behaves like if it was included in a shell, you have to be aware of that values with literal $ signs need to be enclosed in single quotes. This may be the case if you use hashed values of credentials you pass via .env, for example.

adapter

You can specify a class that implements \Helhum\DotEnvConnector\DotEnvVars interface, if you need a different way to expose env vars.

The default value is "Helhum\DotEnvConnector\Adapter\SymfonyDotEnv", which uses symfony/dotenv default parsing of the one .env file.

This could be useful though e.g. if you prefer to use another dotenv parsing library to expose the variables defined in .env or you want to switch to another parsing strategy of the Symfony dotenv parsing. In the latter case use "Helhum\DotEnvConnector\Adapter\SymfonyLoadEnv" as value for this option. Have a look at the existing implementations for examples.

Feedback

Any feedback is appreciated. Please write bug reports, feature request, create pull requests, or just drop me a "thank you" via Twitter or spread the word.

Thank you!


All versions of dotenv-connector with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
composer-plugin-api Version ^1.0 || ^2.0
symfony/dotenv Version ^5.1 || ^6.4 || ^7.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 helhum/dotenv-connector contains the following files

Loading the files please wait ....