dragon-code / env-sync
确保你的 .env.example 文件是最新的
4.1.0
2024-03-13 07:10 UTC
Requires
- php: ^8.0
- dragon-code/support: ^6.0
- symfony/finder: ^4.0 || ^5.0 || ^6.0 || ^7.0
- vlucas/phpdotenv: ^4.0 || ^5.0
Requires (Dev)
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^4.0 || ^5.0 || ^6.0 || ^7.0
Suggests
- dragon-code/env-sync-laravel: env-sync package adapter for Laravel framework
This package is auto-updated.
Last update: 2024-09-13 08:19:14 UTC
README
安装
如果你正在使用 Laravel 框架,请安装 dragon-code/env-sync-laravel 包。
要获取最新版本的 环境同步
,只需使用 Composer 引入项目。
$ composer require dragon-code/env-sync --dev
或者手动更新 require-dev
块中的 composer.json
并运行 composer update
。
{ "require-dev": { "dragon-code/env-sync": "^4.0" } }
如何使用
此包会扫描指定文件夹中具有
*.php
、*.json
、*.yml
、*.yaml
和*.twig
扩展名的文件,从这些文件中接收对env
和getenv
函数的调用。基于接收到的值,该包创建一个键值数组。在保存时,键通过_
字符前的第一个单词进行分割。此外,所有键按字母顺序排序。
框架
- Laravel / Lumen 框架 - 请参阅此存储库中的文档。
原生使用
要在你的应用程序中调用命令,你需要执行以下操作
use DragonCode\EnvSync\Services\Syncer; protected function syncer(): Syncer { return Syncer::make(); } protected function sync() { $this->syncer() ->path(__DIR__) ->filename('.env.example') ->store(); }
如果你想要定义默认值或指定哪些键值应该被存储,你需要将一个数组传递给 Config
类的构造函数
use DragonCode\EnvSync\Services\Syncer; protected function syncer(): Syncer { return Syncer::make($this->config()); } protected function config(): array { return require realpath(__DIR__ . '/your-path/your-config.php'); }
你也可以通过发送 PR 来建议你的实现。我们将非常高兴 😊
许可证
此包根据MIT 许可证授权。