Welcome Guest, Not a member yet? Register   Sign In
multiple instances only config files change
#1

Hello,
i try on google and did not find anything. sorry for my bad English.

i am working bussince application in CI 3. i had multiple clients with same application.
setup different instance but each client had own database and few config parameters on server.
my problem is when i am apply new patch i need to apply it on all instances most of time i forget to apply patch on some instance.


- application server is same.
- domain name different for each client. 
- i am thinking when users hit domain application load specific config folder.

it is possible to setup single application code and multiple config folder?
Reply
#2

Can you supply typical details of "config file changes".


Do all applications share a single system folder?
Reply
#3

(This post was last modified: 08-04-2020, 08:59 PM by blacksmith.)

(08-04-2020, 07:14 PM)John_Betong Wrote: Can you supply typical details of "config file changes".


Do all applications share a single system folder?

yes all application and system folder is same, database name different in database.php and config variables in config.php
PHP Code:
date_default_timezone_set('xxx/xxx');
setlocale(LC_ALL'fil_PH');
$config['diler_prefix'] = 'tel:0';
$config['_login_site_name'] = "ASEAN"

i want to single project folder for patch/update code/changes apply on production and each client instance operate with different database config file variables .
i try google... but not lucky...

it possible to define config folder or only database.php,config.php path in index.php maybe it solve my problem.
Reply
#4

(This post was last modified: 08-04-2020, 10:25 PM by John_Betong.)

I usually test for the server name and set $config values accordingly:

Code:
$_SERVER_NAME = $_SERVER['SERVER_NAME'];

switch($_SERVER_NAME ) :

case 'abc.com':
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0123';
  $config['_login_site_name'] = "ASEAN-001";
break;

case 'xyz.com':
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0456';
  $config['_login_site_name'] = "ASEAN-009";
break;

case 'locahost':
default:
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0456';
  $config['_login_site_name'] = "ASEAN-009";
break;
endswitch;

There are lots of other $_SERVER variables abvaliable:
Code:
echo '<pre>'; // add line feeds
  print_r( $_SERVER);
  die;
Reply
#5

Personally I'm using application environment variables from Apache/Nginx.

PHP Code:
/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT FROM APACHE/NGINX
 *---------------------------------------------------------------
 *
 * Apache: SetEnv VARNAME myvariable
 * Nginx:  fastcgi_param VARNAME myvariable;
 *
 * Required
 * CI_DB_HOSTNAME
 * CI_DB_USERNAME
 * CI_DB_PASSWORD
 * CI_DB_DATABASE
 * CI_BASE_URL
 *
 * Optional
 * CI_BASE_PATH
 * CI_CDN_URL
 * CI_PROGRAM_NAME
 * CI_PROGRAM_DESC
 * CI_PROGRAM_DESC_SHORT
 * CI_SESS_SAVE_PATH
 *
 */ 


In the same way CodeIgniter grabs it's environment variable.

PHP Code:
/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
 *
 * You can load different configurations depending on your
 * current environment. Setting the environment also influences
 * things like logging and error reporting.
 *
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 */
    
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); 

That means you don't need to update your project at all. Everything are done from Apache / Nginx configuration instead.
https://codeigniter.com/userguide3/gener...ments.html
Reply
#6

(08-04-2020, 10:23 PM)John_Betong Wrote: I usually test for the server name and set $config values accordingly:

Code:
$_SERVER_NAME = $_SERVER['SERVER_NAME'];

switch($_SERVER_NAME ) :

case 'abc.com':
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0123';
  $config['_login_site_name'] = "ASEAN-001";
break;

case 'xyz.com':
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0456';
  $config['_login_site_name'] = "ASEAN-009";
break;

case 'locahost':
default:
  date_default_timezone_set('xxx/xxx');
  setlocale(LC_ALL, 'fil_PH');
  $config['diler_prefix'] = 'tel:0456';
  $config['_login_site_name'] = "ASEAN-009";
break;
endswitch;

There are lots of other $_SERVER variables abvaliable:
Code:
  echo '<pre>'; // add line feeds
  print_r( $_SERVER);
  die;
Thank you . and how to handle database  ?
Reply
#7

Same idea, check and set the SERVER_NAME and use the values in ./app/Config/Database.php
Reply
#8

(08-05-2020, 02:05 AM)John_Betong Wrote: Same idea, check and set the SERVER_NAME and use the values in ./app/Config/Database.php

Thank you.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB