Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/68publishers/environment
- Owner: 68publishers
- License: mit
- Created: 2020-05-05T21:33:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T00:54:11.000Z (5 months ago)
- Last Synced: 2024-11-13T14:22:16.000Z (about 2 months ago)
- Topics: composer-plugin, env, environment, nette
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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.
## Installation
```sh
$ composer require 68publishers/environment
```## Usage
### Default ENV variables
The default ENV variables are:
- APP_ENV
- APP_DEBUGBoth 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
```