Welcome Guest, Not a member yet? Register   Sign In
Base_url as a default value in a custom Config file
#4

(This post was last modified: 10-16-2021, 11:17 PM by John_Betong.)

@sevmusic,
>>> Is getting the base_url() possible as a default value in a Config file?

Perhaps consider defining the CONST in index.php and it will be available throughout the application:

file:  /index.php
PHP Code:
# DYNAMIC PATH ===================================================
  # 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
('BASE_URL') ?: define('BASE_URL'$url); # app/Paths.php, etc
# DYNAMIC PATH =================================================== 
[
file: app/Config/App.php
PHP Code:
  public $baseURL BASE_URL// http://localhost:8080/'; 
Reply


Messages In This Thread
RE: Base_url as a default value in a custom Config file - by John_Betong - 10-16-2021, 11:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB