Download the PHP package m1/env without Composer

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

Env

Author Latest Version on Packagist Build Status Coverage Status Quality Score Downloads StyleCI

Sensio badge

Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.

Why?

Env aims to bring a unified parser for env together for PHP rather than having a few incomplete or buggy parsers written into other libraries. This library is not meant as a complete package for config loading like other libraries as this is out of scope for this library. If you need something like that check out Vars which incorporates this library so you can load Env and other file types if you want, or checkout PHP Dotenv if you only need .env parsing

Requirements

Env requires PHP version 5.3+ - supported and tested on 5.3, 5.4, 5.5, 5.6, 7 and hhvm.

Install

Via Composer

Usage

Basic

test.env

example.php

Context variables

test_context.env

example_context.php

Syntax

The Syntax is slightly more relaxed than bash, but still remains quite bash like

Assignment

To assign values the syntax is key = value, unlike bash the assignment is pretty relaxed, any of the below are valid:

However keys can not start with a number, e.g.:

Will throw a ParseException

You can also add export to the start of variables to source the file in bash (see here for more info):

Strings

Strings can either be in quotes (single or double) or without:

To escape new lines or quotes is the standard backslash:

If you feature two quoted strings as a value then only the first quoted string will be assigned to the key:

Numbers

Numbers are fairly standard:

Decimal numbers will be automatically cast to floats:

If you quote numbers they will be counted as strings, or if you have two numbers on one line:

Booleans

Booleans can be true, false, yes and no:

Booleans are case-insensitive:

Booleans in quotes will be treated as strings:

Null

Both of the below are counted as null values:

Whereas an empty string is counted as a string:

Variables

Variables are based of the bash syntax:

The types of variable get passed to the calling variable if there is only one variable. If there are more than one variable, the calling variable is automatically cast to a string:

Also if the variable is in quotes then the variable will be automatically cast as a string:

But you can use variables without quotes and they'll be cast as strings:

Variables are useful to use in strings like so:

Null values are passed and casted as empty strings if in quotes:

Single Quotes with variables will be counted as strings:

Parameter Expansion

You can do parameter expansion, so far you can only do default values and assign default values like in the bash syntax:

The default value parameter expansion syntax is :-, the explanation on the bash-hackers wiki for this is:

SYNTAX:

${PARAMETER:-WORD}

${PARAMETER-WORD}

If the parameter PARAMETER is unset (never was defined) or null (empty), this one expands to WORD, otherwise it expands to the value of PARAMETER, as if it just was ${PARAMETER}. If you omit the : (colon), like shown in the second form, the default value is only used when the parameter was unset, not when it was empty.

For example:

The assign default value parameter expansion is :=, the explanation on the bash-hackers wiki for this is:

SYNTAX:

${PARAMETER:=WORD}

${PARAMETER=WORD}

This one works like the using default values, but the default text you give is not only expanded, but also assigned to the parameter, if it was unset or null. Equivalent to using a default value, when you omit the : (colon), as shown in the second form, the default value will only be assigned when the parameter was unset.

For example:

Comments

To comment, just use the # syntax, you can also comment inline like so:

If you put a # without a space in a unquoted string, it will be parsed as a string:

.env example

The result from this library and the expected result of the above is:

Notes

Source

If you need the .env variables in other applications, you can source the env, but make sure it's valid bash syntax, as this parser allows a more relaxed form of bash syntax.

This library will always be able to parse bash syntax, but for now the opposite (env syntax -> bash syntax) may not be true, however this is being worked on to bring a strict parser version for 3.0

Other library comparisons

The difference between this library and other similar libraries:

zrcing/phpenv:

Dotenv\Dotenv:

Todo

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of env with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 m1/env contains the following files

Loading the files please wait ....