如何在 .env 或 config/myconfig.php 上提交表单值?
How to submit form value on .env or config/myconfig.php?
我有一个用于管理数据的 CRM,到目前为止还不错。我正在考虑在我的 CRM 上添加一些 settings
额外选项,我正在考虑 route /setting-value
并在此显示表单。我的意思是,当用户走这条路来根据自己的喜好对 CRM 进行个性化设置时,例如站点名称、正文背景颜色、站点描述,可能会更改数据库配置。我知道这个配置与 .env
和 config/myconfig.php
有关,但我不知道如何在 .env
或我的配置上传递这个提交表单,它是如何工作的。我在 google 上进行了搜索,但没有找到任何关于此的好文档。有人有想法吗?
您可以使用此包进行 .env 编辑geo-sot/laravel-env-editor
composer require geo-sot/laravel-env-editor
当您在控制器中提交表单时,您可以使用这些函数进行各种操作
EnvEditor::getEnvFileContent($fileName='')
// Return The .env Data as Collection.
// If FileName Is provided it searches inside backups Directory and returns these results
EnvEditor::keyExists($key)
// Search key existance in .env
EnvEditor::getKey(string $key, $default = null)
// Get key value from .env,
EnvEditor::addKey($key, $value, array $options = [])
// Adds new Key in .env file
// As options can pass ['index'=>'someNumericIndex'] in order to place the new key after an other and not in the end,
// or ['group'=>'MAIL/APP etc'] to place the new key oat the end of the group
EnvEditor::editKey($key, $value)
// Edits existing key value
EnvEditor::deleteKey($key)
我有一个用于管理数据的 CRM,到目前为止还不错。我正在考虑在我的 CRM 上添加一些 settings
额外选项,我正在考虑 route /setting-value
并在此显示表单。我的意思是,当用户走这条路来根据自己的喜好对 CRM 进行个性化设置时,例如站点名称、正文背景颜色、站点描述,可能会更改数据库配置。我知道这个配置与 .env
和 config/myconfig.php
有关,但我不知道如何在 .env
或我的配置上传递这个提交表单,它是如何工作的。我在 google 上进行了搜索,但没有找到任何关于此的好文档。有人有想法吗?
您可以使用此包进行 .env 编辑geo-sot/laravel-env-editor
composer require geo-sot/laravel-env-editor
当您在控制器中提交表单时,您可以使用这些函数进行各种操作
EnvEditor::getEnvFileContent($fileName='')
// Return The .env Data as Collection.
// If FileName Is provided it searches inside backups Directory and returns these results
EnvEditor::keyExists($key)
// Search key existance in .env
EnvEditor::getKey(string $key, $default = null)
// Get key value from .env,
EnvEditor::addKey($key, $value, array $options = [])
// Adds new Key in .env file
// As options can pass ['index'=>'someNumericIndex'] in order to place the new key after an other and not in the end,
// or ['group'=>'MAIL/APP etc'] to place the new key oat the end of the group
EnvEditor::editKey($key, $value)
// Edits existing key value
EnvEditor::deleteKey($key)