moh-slimani/laravel-env-write

A package to write to the .env file.

0.0.1 2024-02-29 05:49 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

LaravelEnvWrite is a Laravel package designed to simplify the process of updating the .env file in Laravel applications. It provides a convenient way to automatically update the environment file during database seeding or from anywhere in the codebase.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require moh-slimani/laravel-env-write

Configuration

The package doesn't require any additional configuration. Once installed, you can start using it immediately.

Usage

Command Line Interface

The package provides an Artisan command to update the .env file from the command line.

php artisan env:write {key} {value?}
  • {key}: The key to update in the .env file. It can be provided either as a single argument or in the format key=value.
  • {value}: The value to set for the key. This argument is optional and only required when providing a single argument for the key.

Examples

php artisan env:write APP_ENV production
php artisan env:write APP_KEY=your_app_key

Programmatically

You can also use the package programmatically in your codebase:

use MohSlimani\LaravelEnvWrite\Facades\LaravelEnvWrite;

// Update the environment file with a specific key and value
LaravelEnvWrite::updateEnvironmentFileWith('APP_ENV', 'production');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.