harmonic/laravel-envcoder
Composer 安装命令:
composer require harmonic/laravel-envcoder
包简介
:description
README 文档
README
Encrypts your Laravel .env so that it can be securely stored in source control and decrypted via a password.
It was written to quickly and easily share .env variables within source control instead of having to manually pass around variables or look them up in various 3rd party services.
Some highlights of the package include:
- Commit an encrypted version of your .env into source control to share with your team
- Written to be used in various automated deployment processes (password can be stored locally, conflict resolution)
- Can be configured to overwrite, merge, or interactively decide how to deal with merge conflicts within your .env
- Does not require any changes to your project to retrieve .env variables
- Simply edit your .env files as normal (and encrypt them when you are ready to share)
- Compare your encrypted .env with the current one and see what's different
Installation
Via Composer
$ composer require harmonic/laravel-envcoder --dev
Publish the config file (optional)
php artisan vendor:publish --provider="harmonic\LaravelEnvcoder"
Configuration
After publishing the config you can change the default behaviour for environment variable conflict resolution in config/envcoder.php.
- 'merge' => Will merge changes in both files, and overwrite duplicates with what is in .env.enc (default)
- 'prompt' => Will prompt you for each value that has a different value in .env.enc vs .env or is not in both files
- 'overwrite' => Will completely overwrite your .env with what is in the encrypted version
- 'ignore' => Will ignore any changes in your encrypted .env (ie. will not decrypt)
See config/envcoder.php for more details.
Usage
Encypting your .env
From your project root simply run:
php artisan env:encrypt
You will be prompted for a password, if you prefer to enter it from the command line you can use
php artisan env:encrypt --password=password
(replace password with your password)
Encypting another .env file
If you have multiple .env files you can add an option (--s or --source) to the encrypt command to tell Envcoder to encrypt that file instead. Envcoder will create an encrypted file with the same name and .enc appended.
php artisan env:encrypt -s .env.testing
Decrypting your .env
From your project root simply run:
php artisan env:decrypt
You will be prompted for a password, if you prefer to enter it from the command line you can use
php artisan env:decrypt --password=password
(replace the second password with your password)
Encypting another .env file
If you have encrypted an .env file with a different name (such as .env.testing) you can add an option (--s or --source) to the decrypt command to tell Envcoder to decrypt that file instead.
php artisan env:decrypt --source .env.testing.enc
This will produce a .env.testing file.
Compare .env.enc with .env (Diff)
You can review any changes between your current .env and the encrypted one:
php artisan env:compare --password=password
(replace the second password with your password)
Include password in your .env file
You can add a variable to your .env file with the variable ENV_PASSWORD. This will be removed from the encrypted version but will allow simple encoding/decoding in development with no need for password. Simply add to your .env:
ENV_PASSWORD=passwordHere
(replace passwordHere with your password)
This way you will not be prompted for a password each time you encrypt/decrypt the .env file.
Some usage suggestions
You may wish to have your production deployment script delete the .env.enc file from your server each time you deploy.
If you include the password in your .env file for local development you could add the env:decrypt command to your composer post-install section to automatically updte your .env file each time you do a composer install, eg.
"scripts": { "post-install-cmd": [ "@php artisan env:decrypt" ] }
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ phpunit
Contributing
Please see contributing.md for details and a todolist.
Security
We have selected the defuse\php-encryption package to handle the encryption and decryption of the .env file due to its ease of use and security. With that said, storing an encrypted .env file in your source control is less secure than not storing it at all. We believe only marginally, but it's up to you to weigh up the security vs. convience and make a decision for your project.
If you discover any security related issues, please email craig@harmonic.com.au instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
harmonic/laravel-envcoder 适用场景与选型建议
harmonic/laravel-envcoder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.08k 次下载、GitHub Stars 达 41, 最近一次更新时间为 2019 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「environment」 「.env」 「laravel-envcoder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 harmonic/laravel-envcoder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 harmonic/laravel-envcoder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 harmonic/laravel-envcoder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Environment processor and contexts autoloader
The tenancy/tenancy identification driver using environment variables
Companion for .env files
dotenv integration into Nette framework
Multiple cascading environmental configuration files support for Laravel 5
An environment variable convenience library extension for vlucas/phpdotenv
统计信息
- 总下载量: 4.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 41
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-21
