Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tal7aouy/dotenv
A PHP Package for editing dotenv files
https://github.com/tal7aouy/dotenv
dotenv dotenv-editor
Last synced: about 2 months ago
JSON representation
A PHP Package for editing dotenv files
- Host: GitHub
- URL: https://github.com/tal7aouy/dotenv
- Owner: tal7aouy
- License: mit
- Created: 2022-04-19T12:45:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T12:55:38.000Z (over 2 years ago)
- Last Synced: 2024-05-14T08:02:00.201Z (7 months ago)
- Topics: dotenv, dotenv-editor
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Dotenv editing
[![Latest Version on Packagist](https://img.shields.io/packagist/v/tal7aouy/dotenv.svg?style=flat-square)](https://packagist.org/packages/tal7aouy/dotenv)
[![Total Downloads](https://img.shields.io/packagist/dt/tal7aouy/dotenv.svg?style=flat-square)](https://packagist.org/packages/tal7aouy/dotenv)
![run-tests](https://github.com/tal7aouy/dotenv/workflows/run-tests/badge.svg)This package provides some basic tools for editing dotenv files.
## Installation
You can install the package via composer:```bash
composer require tal7aouy/dotenv
```## Usage
### Add a section
Given we have an existing file at `base_path('.env')`.
We can add a new section to the existing configuration file.
``` php
$dotenv = new Dotenv();$dotenv->load(base_path('.env'));
$dotenv->heading('DB_CONNECTION');
$dotenv->set('DB_CONNECTION', 'mysql');
$dotenv->set('DB_HOST', '127.0.0.1');
$dotenv->set('DB_PORT', '3306');
$dotenv->set('DB_DATABASE', 'demo');
$dotenv->set('DB_USERNAME', 'root');
$dotenv->set('DB_PASSWORD', '');
$dotenv->getEnv('DB_DATABASE'); // demo
$dotenv->save();
```This will result in the following changes.
```
APP_KEY=supersecret# DB_CONNECTION
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=demo
DB_USERNAME=root
DB_PASSWORD=
```## Testing
```bash
> composer test
```## Code Style
StyleCI will apply the [Laravel preset](https://docs.styleci.io/presets#laravel).## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.## Credits
- [Mhammed Talhaouy](https://github.com/tal7aouy)## License
Please see [License File](LICENSE.md) for more information.