Jump to content

Configure environment specific variables (configuration.php?)


Robby_D

Recommended Posts

Hi,

 

First of all let me start by saying I have virtually no whmcs experience as of yet, only started working with it yesterday as I joined a project where 1 dev was working on. I have experience as a PHP dev so I'm learning fast and I find WHMCS to be pretty straight forward. I have searched the forum and documentation but could not find an answer to my issue.

 

As part of me joining the project we added a second server for me to work on. To keep track of code changes I've set up git so that when I finish my work I should be able to just push any branch to my coworker's setup, he can review and merge it in.

 

Initially I excluded the configuration.php file from our git repository so that we're not tracking that for changes.

 

So here's the catch, some of our modules/addons contain environment specific variables.

 

In my experiences from the past I've always added a config file, check the system env variable and set these variables globally according to the env being 'prod', 'test' or 'dev' or whatever.

 

So my question now is would configuration.php (as it already contains environment specific variables like db_host, db_username, license, ...) be a good place to store these? Can I just do something like:

 

<?php
if(isset($_SERVER['APPLICATION_ENV']) && $_SERVER['APPLICATION_ENV'] == 'dev') {
   $license = 'lalalDEV';
   $db_host = 'lalalaDEV';
   ...
   $customVar = 'lalalaDEV';
);
else{
   $license = 'lalalPROD';
   $db_host = 'lalalaPROD';
   ...
   $customVar = 'lalalaPROD';
};
?>

 

I'm asking this specifically because I noticed when setting up the license using the front-end, the key was written into the file so I'm nog sure if this would work or be good practice.

 

Seeing as I can't be the only one having tried to accomplish this I took it to the forums, thanks in advance for any help!

Link to comment
Share on other sites

  • 7 years later...

Bumping the thread. Our team is currently needing a common file to store constants, so we don't have to repeat them in each of our  addon module's  configuration. We thought configuration.php would be a good place to do so but the variables don't seem to work well in some cases when required and accesed in the modules. I couldn't find any specific documentation page  for  the configuration.php file, I think one should be made since it's a very important file and there are some variables that seem to be keywords to define certain built-in whmcs configurations (like $display_errors="true"/"false")

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated