baglerit/envariable
最新稳定版本:5.0.1
Composer 安装命令:
composer require baglerit/envariable
包简介
Adds an Artisan command, envariable:encrypt, which adds an encrypted variable to the .env file.
README 文档
README
Add an Artisan command, envariable:encrypt, which adds an encrypted environement variable to the .env file.
Laravel version
This tool was developed and tested using Laravel 5.0.
Installation
- Require this package in your Laravel project:
composer require baglerit/envariable
- Add a line in
app/Console/Kernel.phpto register this command:
protected $commands = [ ... \BaglerIT\EnVariableCommand\EnVariableCommand::class, ];
Decryption Examples
Here are two examples of ways you may want to access environment variables.
With Crypt Facade
Here's how you can decrypt the variables if you are loading the environment variable where you are able to use the
Crypt facade.
use Illuminate\Support\Facades\Crypt; ... try { $value = Crypt::decrypt(env('VAR_NAME')); } catch(DecryptException $e) { ... }
Without Crypt Facade
(Thanks to @bobbybouwmann, for helping with this.)
My environment variables are often used by files within my Laravel project's config folder such as
config/auth.php and config/database.php. Unfortunately the Crypt facade is not available
within config files so you will need to create a new Encrypter object.
$crypt = new Illuminate\Encryption\Encrypter(env('APP_KEY')); ... 'mysql' => [ 'driver' => 'mysql', 'host' => $crypt->decrypt(env('DB_HOST')), 'database' => $crypt->decrypt(env('DB_DATABASE')), 'username' => $crypt->decrypt(env('DB_USERNAME')), 'password' => $crypt->decrypt(env('DB_PASSWORD')), 'port' => $crypt->decrypt(env('DB_PORT')), ...
Warnings
- Make sure you decrypt your encrypted environment variables before using them in your application.
- This command does not check if the environment variable already exists so please check your
.envfile to ensure you have not created duplicate variables. - This command encrypts data but stores it in the same file as the encryption key so it isn't a substitute for existing security best practises. I wrote this command because I needed to encrypt an app token in order to meet a third-party security requirement. Please don't assume that this command makes your data any more secure.
baglerit/envariable 适用场景与选型建议
baglerit/envariable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 769 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 baglerit/envariable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 baglerit/envariable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 769
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-23