Welcome Guest, Not a member yet? Register   Sign In
Is it possible to move Config folder into root?
#5

(This post was last modified: 09-14-2020, 01:28 PM by T.O.M..)

(09-13-2020, 06:43 PM)MrWhite Wrote: But the problem is config options like supportedLocales, appTimezone are not available in the .env file. but only available in the App.php config file.

Wrong. In .env file you can set any config option from any config file https://codeigniter.com/user_guide/gener...-variables

You can see an example of .env file - here you can see that there are options from App.php, Database.php and other config files from app/Config.


(09-14-2020, 05:54 AM)John_Betong Wrote: I generate a "LOCALHOST" constant in index.php and used in Config.php and Database.php to modify variables. I also generate a JB_BASEURL which is used in Config.php. to set $base_url.

File: Index.php
PHP Code:
define('LOCALHOST''localhost'===$_SERVER['SERVER_NAME']);

# dynamic BaseUrl - https://forum.codeigniter.com/thread-74649.html  
  if( TRUE || DEFINED('AUTOMATIC_URL_DETECTION') ) :
    $url = (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) 
        && 
        ('on' == $_SERVER['HTTPS']) 
        "https://" 
        "http://") .$_SERVER['HTTP_HOST']
        ;
    $url .= str_replace
    
(
      basename($_SERVER['SCRIPT_NAME']), 
      ''
      $_SERVER['SCRIPT_NAME']
    );
  endif;  
  defined
('JB_BASEURL') ?: define('JB_BASEURL'$url); # app/Paths.php, etc 

You can get rid of all this by adding different .env files to different environments.

Besides you can use CI_ENVIRONMENT variable https://codeigniter.com/user_guide/gener...ments.html
Reply


Messages In This Thread
RE: Is it possible to move Config folder into root? - by T.O.M. - 09-14-2020, 01:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB