Support the ongoing development of Laravel.io →
Configuration Architecture
Last updated 2 years ago.
0

I had a solution with codegniter. i think laravel maybe use. I make administrator for all website user app. one user will use one database (same structure database). First you have change index.php of laravel (root) to define domain, info mysql....... in folder user make index.php include index.php (root). This my index.php of user

<?php
if(!file_exists("config.ini")){
  echo '<script>window.location.replace("install.php");</script>';
}
else {
  $vietcms_config = file_get_contents("config.ini");
  $configs = json_decode($vietcms_config);
  foreach($configs as $config){
    if($config->name == "define"){
      define($config->value->name,$config->value->value);
    }
    elseif($config->name == "include"){
      include($config->value);
    }
  }
  }
?>

and this file config.ini

[{"name":"define","value":{"name":"HOSTNAME","value":"localhost"}},{"name":"define","value":{"name":"USERHOST","value":"root"}},{"name":"define","value":{"name":"PASSHOST","value":"admin"}},{"name":"define","value":{"name":"PREFIXHOST","value":"vietcms_"}},{"name":"define","value":{"name":"DATAHOST","value":"test"}},{"name":"define","value":{"name":"ADMIN_PATH","value":"admin"}},{"name":"define","value":{"name":"CONTACT","value":"lien-he"}},{"name":"define","value":{"name":"CART","value":"gio-hang"}},{"name":"define","value":{"name":"BASE_URL","value":"http:\/\/demo.com"}},{"name":"define","value":{"name":"FILE_FRAMEWORK","value":"F:\\PHP\\Xampp\\htdocs\\Project\\quanly\\index.php"}},{"name":"include","value":"F:\\PHP\\Xampp\\htdocs\\Project\\quanly\\index.php"}]

And index.php (root) has been change

.................
if (defined('BASE_URL')) {}
    else {
        define('BASE_URL','http://quanly.com');
    }
    if (defined('HOSTNAME')) {}
    else {
        define('HOSTNAME','localhost');
    }
    if (defined('USERHOST')) {}
    else {
        define('USERHOST','root');
    }
    if (defined('PASSHOST')) {}
    else {
        define('PASSHOST','admin');
    }
    if (defined('PREFIXHOST')) {}
    else {
        define('PREFIXHOST','vietcms_');
    }
    if (defined('DATAHOST')) {}
    else {
        define('DATAHOST','quanly');
    }if (defined('ADMIN_PATH')) {}
    else {
        define('ADMIN_PATH','admin');
    }if (defined('CONTACT')) {}
    else {
        define('CONTACT','contact');
    }if (defined('CART')) {}
    else {
        define('CART','cart');
    }
....................

after i can use http://demo.com use all app in http://master.com With config.ini you can change anything (admin path, domain.......) My project run very well. Multi website, multi language Sorry for my english poor

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.