Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apolloeleven/env-analyzer
Analyzes environment files
https://github.com/apolloeleven/env-analyzer
analyzer composer-scripts env-analyzer php yii2-extension yii2-framework yii2-package
Last synced: 3 months ago
JSON representation
Analyzes environment files
- Host: GitHub
- URL: https://github.com/apolloeleven/env-analyzer
- Owner: apolloeleven
- Created: 2018-04-02T08:01:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-13T16:33:01.000Z (over 6 years ago)
- Last Synced: 2024-09-30T23:44:54.652Z (3 months ago)
- Topics: analyzer, composer-scripts, env-analyzer, php, yii2-extension, yii2-framework, yii2-package
- Language: PHP
- Size: 13.7 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Env / PHP analyzer
Analyzes env dist file and allows to insert missing variables to env file through the console
# Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).Either run
```
php composer.phar require --prefer-dist apollo11/env-analyzer "~1.0"
```or add
```
"apollo11/env-analyzer": "~1.0"
```to the require section of your `composer.json` file and run `php composer.phar update` command.
The package offers:
1. [Env](https://github.com/apolloeleven/env-analyzer/blob/master/Env.php) class which can store `.env` and `.env.dist` file path, as well as, getting the difference between those files.
2. [Php](https://github.com/apolloeleven/env-analyzer/blob/master/Php.php) class which can store `env.php` and `env.dist.php` file path, as well as, getting the difference between those files. Note: both `php` files should return Associative array either strings or integers.
3. [Analyzer](https://github.com/apolloeleven/env-analyzer/blob/master/Analyzer.php) class which is used for getting the difference of files through the consoleBasic Usage
-----
Generally, the best use case is to call [Analyzer](https://github.com/apolloeleven/env-analyzer/blob/master/Analyzer.php) from console, because it gives the ability to insert the value of the missing data, as well.Add the following code to your console command
```
Analyzer::analyzeEnv($pathToEnv, $pathToEnvDist);
```or add
```
Analyzer::analyzePhp($pathToPhp, $pathToDistPhp);
```Usage from Composer
-----You can also run [Analyzer](https://github.com/apolloeleven/env-analyzer/blob/master/Analyzer.php) on [Composer Scripts](https://getcomposer.org/doc/articles/scripts.md)
Add the following code to the `extra` in project's `composer.json` file
```
"apollo11-parameters": {
//env-path and env-dist-path for analyzing env files
"env-path": ".env",
"env-dist-path": ".env.dist",
//php-env-path and php-env-dist-path for analyzing php files
"php-env-path": "env.php",
"php-env-dist-path": "env.dist.php"
},
```You should also call the analyzer method from composer script. In this example, I call it from `post-install-cmd`, which is triggered after `composer install` is finished. Just add the following code to script in `composer.json` file
```
"post-install-cmd": [
//Analyzer for env files
"\\apollo11\\envAnalyzer\\Analyzer::analyzeEnvComposer",
//Analyzer for php files
"\\apollo11\\envAnalyzer\\Analyzer::analyzePhpComposer"
],
```