Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/68publishers/environment

:atom: The component for loading the ENV variables and detecting a debug mode
https://github.com/68publishers/environment

composer-plugin env environment nette

Last synced: 28 days ago
JSON representation

:atom: The component for loading the ENV variables and detecting a debug mode

Awesome Lists containing this project

README

        

Environment

The component based on the symfony/dotenv for simple loading of the ENV variables and detecting a debug mode.


Checks
Coverage Status
Total Downloads
Latest Version
PHP Version

## Installation

```sh
$ composer require 68publishers/environment
```

## Usage

### Default ENV variables

The default ENV variables are:

- APP_ENV
- APP_DEBUG

Both variables will be always accessible in the global arrays `$_ENV` and `$_SERVER`.
The default value for `APP_ENV` is `dev` and `0` for `APP_DEBUG`.

### ENV variables loading

For ENV variables loading call this static method after requiring Composer's autoload and before your application is stared.
The first argument is a relative path to the application root directory and the second argument is an array of debug mode detectors.

```php

or shorter

$ composer dump-env
```

The file `.env.local.php` will be created in the application's root directory, and it will be used instead of all your `.env` files.

### Nette DI Extension

The package includes the Compiler Extension to Nette DI. Its registration is not necessary for variables loading to work, but it adds two console commands to the application.

```neon
extensions:
environment: SixtyEightPublishers\Environment\Bridge\Nette\DI\EnvironmentExtension
```

#### Command `dotenv:dump`

The command works just like the composer command. The `env` argument is optional here, the current `APP_ENV` of the application is used as the default value.

```sh
$ bin/console dotenv:dump [] [--empty]
```

#### Command `debug:dotenv`

The command lists all dotenv files with variables and values.

```sh
$ bin/console debug:dotenv
```

## Contributing

Before opening a pull request, please check your changes using the following commands

```bash
$ make init # to pull and start all docker images

$ make cs.check
$ make stan
$ make tests.all
```