https://github.com/sixlive/dotenv-editor
A PHP Package for editing dotenv files
https://github.com/sixlive/dotenv-editor
dotenv dotenv-editor php
Last synced: 10 months ago
JSON representation
A PHP Package for editing dotenv files
- Host: GitHub
- URL: https://github.com/sixlive/dotenv-editor
- Owner: sixlive
- License: mit
- Created: 2018-08-17T01:23:07.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T14:46:46.000Z (over 1 year ago)
- Last Synced: 2025-04-06T03:51:14.435Z (10 months ago)
- Topics: dotenv, dotenv-editor, php
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 74
- Watchers: 1
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Dotenv editing toolset
[](https://packagist.org/packages/sixlive/dotenv-editor)
[](https://packagist.org/packages/sixlive/dotenv-editor)

This package provides some basic tools for editing dotenv files.
## Installation
You can install the package via composer:
```bash
> composer require sixlive/dotenv-editor
```
## Usage
### Add a section
Given we have an existing file at `base_path('.env')`.
```
APP_KEY=supersecret
APP_FOO=BAR
```
We can add a new section to the existing configuration file.
``` php
$editor = new DotenvEditor;
$editor->load(base_path('.env'));
$editor->heading('Examples');
$editor->set('FOO', 'bar');
$editor->set('BAZ', 'bax');
$editor->unset('APP_FOO');
$editor->save();
```
This will result in the following changes.
```
APP_KEY=supersecret
# Examples
FOO=bar
BAZ=bax
```
## Testing
```bash
> vendor/bin/phpunit
```
## 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 oss@tjmiller.co instead of using the issue tracker.
## Credits
- [TJ Miller](https://github.com/sixlive)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.