|
| 1 | +# Laravel `set:env` Command |
| 2 | + |
| 3 | +[](https://packagist.org/packages/imliam/laravel-env-set-command) |
| 4 | +[](https://packagist.org/packages/imliam/laravel-env-set-command) |
| 5 | +[](LICENSE.md) |
| 6 | + |
| 7 | +Set a .env file variable from the command line. |
| 8 | + |
| 9 | +<!-- TOC --> |
| 10 | + |
| 11 | +- [Laravel `set:env` Command](#laravel-setenv-command) |
| 12 | + - [Installation](#installation) |
| 13 | + - [Usage](#usage) |
| 14 | + - [Changelog](#changelog) |
| 15 | + - [Contributing](#contributing) |
| 16 | + - [Security](#security) |
| 17 | + - [Credits](#credits) |
| 18 | + - [License](#license) |
| 19 | + |
| 20 | +<!-- /TOC --> |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +You can install the package with [Composer](https://getcomposer.org/) using the following command: |
| 25 | + |
| 26 | +```bash |
| 27 | +composer require imliam/laravel-env-set-command:^1.0.0 |
| 28 | +``` |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +When running the `env:set` artisan command, you must provide both a key and value as two arguments. |
| 33 | + |
| 34 | +```bash |
| 35 | +$ php artisan env:set app_name Example |
| 36 | +# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'Example' |
| 37 | +``` |
| 38 | + |
| 39 | +You can also set values with spaces by wrapping them in quotes. |
| 40 | + |
| 41 | +```bash |
| 42 | +$ php artisan env:set app_name "Example App" |
| 43 | +# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to '"Example App"' |
| 44 | +``` |
| 45 | + |
| 46 | +The command will also create new environment variables if an existing one does not exist. |
| 47 | + |
| 48 | +```bash |
| 49 | +$ php artisan env:set editor=vscode |
| 50 | +# Environment variable with key 'EDITOR' has been set to 'vscode' |
| 51 | +``` |
| 52 | + |
| 53 | +Instead of two arguments split by a space, you can also mimic the `.env` file format by supplying `KEY=VALUE`. |
| 54 | + |
| 55 | +```bash |
| 56 | +$ php artisan env:set app_name=Example |
| 57 | +# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'Example' |
| 58 | +``` |
| 59 | + |
| 60 | +The command will do its best to stop any invalid inputs. |
| 61 | + |
| 62 | +```bash |
| 63 | +$ php artisan env:set @pp_n@me Laravel |
| 64 | +# Invalid environment key. Only use letters and underscores |
| 65 | +``` |
| 66 | + |
| 67 | +## Changelog |
| 68 | + |
| 69 | +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. |
| 70 | + |
| 71 | +## Contributing |
| 72 | + |
| 73 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 74 | + |
| 75 | +### Security |
| 76 | + |
| 77 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 78 | + |
| 79 | +## Credits |
| 80 | + |
| 81 | +- [Liam Hammett](https://github.com/imliam) |
| 82 | +- [All Contributors](../../contributors) |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments