Issue
I have a CRM for managing data, so far so good. I am thinking to add some settings
extra option on my CRM, i am thinking for a route /setting-value
and on this to display a form. I mean when a user go to this route to personalize CRM as his like, for example site-name, body-background-color, site-description, maybe to change db config. I know this config have to do with .env
and config/myconfig.php
, what i don't know is how to pass this submit form on .env
or my config, how it really works. I have search on google but i didn't find any good documentation about this. Any one have an idea?
Solution
you can use this package for .env editing geo-sot/laravel-env-editor
composer require geo-sot/laravel-env-editor
when you submit the form in your controller you can use these functions for various operations
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)
Answered By - Rashmi Ranjan Sahoo Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.