boomdraw/laravel-dotenv
Composer 安装命令:
composer require boomdraw/laravel-dotenv
包简介
Laravel dotenv manager
README 文档
README
The package that allows read and write .env file variables
Installation
Via Composer
composer require boomdraw/laravel-dotenv
The package will automatically register itself.
You can publish the config file with:
php artisan vendor:publish --provider="Boomdraw\Dotenv\DotenvServiceProvider" --tag="config"
Usage and methods
use Dotenv; //or use Boomdraw\Dotenv\Facades\Dotenv; //or use Boomdraw\Dotenv\Contracts\DotenvContract; class Controller { /** * @var \Boomdraw\Dotenv\Repositories\DotenvRepository */ protected $dotenv; public function __construct(DotenvContract $dotenv) { $this->dotenv = $dotenv; } }
all
Dotenv::all(): Collection
The function returns all .env vars as an \Illuminate\Support\Collection object.
set
Dotenv::set($key, ?string $value = null): self
The function writes the .env variable regardless of the variable existence.
Dotenv::setEmpty($key, ?string $value = null): self
The function writes the .env variable if it does not exist or empty.
add
Dotenv::add($key, ?string $value = null): self
The function adds the .env variable if does not exist.
put
Dotenv::put($key, ?string $value = null): self
The function updates .env variable if it exists.
Dotenv::putEmpty($key, ?string $value = null): self
The function updates .env variable if it exists and empty.
delete
Dotenv::delete($key): self
The function deletes .env variable.
An array of keys to delete can be passed as $key variable.
Setters features
You can pass data as an array for setters (set, add, put):
Dotenv::set['key1' => 'value1', 'key2' => 'value2']
Setters transform variable name removing quotes (', "),
replacing spaces ( ) and hyphens (-) with an underscore (_) and transforming name to uppercase.
For example Dotenv::set('foo bar', 'baz') will write FOO_BAR=baz to .env file.
All setters and delete will rewrite .env file immediately.
reload
Dotenv::reload(): self
The function reloads .env file from the filesystem.
Collection methods
You can call all of Collection methods. For example:
Dotenv::get('APP_NAME') returns APP_NAME value.
Dotenv::has('APP_NAME') checks APP_NAME variable existence.
All collection methods are called for Dotenv collection copy, so any changes to collection will not affect .env file
and Dotenv content.
Testing
You can run the tests with:
composer test
Security
If you discover any security related issues, please email pkgsecurity@boomdraw.com instead of using the issue tracker.
License
boomdraw/laravel-dotenv 适用场景与选型建议
boomdraw/laravel-dotenv 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「env」 「dotenv」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 boomdraw/laravel-dotenv 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 boomdraw/laravel-dotenv 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 boomdraw/laravel-dotenv 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An environment variable convenience library extension for vlucas/phpdotenv
Utils to load, parse and work with configuration on Mezzio projects
Env builder is a package which collects different env files within a specified directory and compiles them into one single .env file, useful when you have different .env files laying around in different folders and you want to have one single big file that you can load with Symfony's DotEnv loader o
.env file handler
Alfabank REST API integration
Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER`, and Docker secrets automagically.
统计信息
- 总下载量: 3.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-03