PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 21, 2022

[FIXED] How to submit form value on .env or config/myconfig.php?

 August 21, 2022     environment-variables, laravel, mysql, php     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing