Welcome Guest, Not a member yet? Register   Sign In
Getting Started with CodeIgniter 4 PreAlpha 1
#14

I have used CI for quite some time and created all localhost files to be a mirror image of the onsite files. This was done by creating the following constant:

PHP Code:
defined('LOCALHOST') || define('LOCALHOST''localhost'===$_SERVER['SERVER_NAME']); 

Differences such as paths, adverts, display Analytics, etc could then be switched out locally using the following:

PHP Code:
if( ! LOCALHOST):
    require 
VIEWPATH .'incs/adverts-800x160.php';
    require 
VIEWPATH .'incs/analytics.php';
endif; 


I tried using this method with the CI4 installation and the class namespace created problems Sad

I eventually managed to find a solution by using the following:
.htaccess
Code:
# Sets the environment that CodeIgniter
   SetEnv CI_ENVIRONMENT  development
   SetEnv LOCALHOST       true
   SetEnv CI_SYSDIR      /home/john/www/ci2/CodeIgniter4/system
   SetEnv CI_SERVER      thisisatesttoseeifitworks.ga/
   SetEnv CI_PUBDIR      public_html

index.php
PHP Code:
# SetVar Constants MUST BE SET IN .htaccess
  
defined('LOCALHOST') || define('LOCALHOST'getenv('LOCALHOST') );
  
defined('CI_SERVER') || define('CI_SERVER'getenv('CI_SERVER') );
  
defined('CI_SYSDIR') || define('CI_SYSDIR'getenv('CI_SYSDIR') );
  
defined('CI_PUBDIR') || define('CI_PUBDIR'getenv('CI_PUBDIR') ); 

These two files require modifing:
./Config/App.php
PHP Code:
    # public $systemDirectory = '../system';
    
public $systemDirectory CI_SYSDIR;     // '/home/john/www/ci2/CodeIgniter4/system';
    
public $baseURL 'https://' .CI_SERVER// ''; 

./Config/Paths.php
PHP Code:
public $publicDirectory CI_PUBDIR ;  // 'public'; // public'; 

Using this technique gives peace of mind knowing that any file modified locally will not create problems when uploaded.

I have just used the above method and the installation worked first time!

I was wondering if this could be applied to the current CI4 installation?
Reply


Messages In This Thread
RE: Getting Started with CodeIgniter 4 PreAlpha 1 - by John_Betong - 06-13-2017, 12:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB