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

(02-20-2017, 02:10 PM)baselbj Wrote:
(06-26-2016, 08:24 PM)kilishan Wrote: One thing I forgot to mention in that post, but that is worth knowing is that the default environment is now "production" to save any accidents when pushing to a live site. To change the environment to development, the best thing is to edit the .htaccess file (if using Apache) that came with the download. Toward the top is a line like:

Code:
# SetEnv CI_ENV development

Uncomment that line and you're good to go.

How to do this in nginx?

Code:
fastcgi_param CI_ENV development;
Reply
#12

(02-21-2017, 02:10 AM)Narf Wrote:
(02-20-2017, 02:10 PM)baselbj Wrote:
(06-26-2016, 08:24 PM)kilishan Wrote: One thing I forgot to mention in that post, but that is worth knowing is that the default environment is now "production" to save any accidents when pushing to a live site. To change the environment to development, the best thing is to edit the .htaccess file (if using Apache) that came with the download. Toward the top is a line like:

Code:
# SetEnv CI_ENV development

Uncomment that line and you're good to go.

How to do this in nginx?

Code:
fastcgi_param CI_ENV development;

Thank You Smile
Reply
#13

I've played with CI4 and I don't know where is the proper place to mention mistakes in the documentation and errors in CI itself. A few problems that I've found:

- The correct place of .env files is not the /application directory, but the root directory (where the composer.json lives).
- $_ENV global variable and getenv function works normally, but if I try to use them in the Database config I get the following error:
Fatal error: Constant expression contains invalid operations in /media/sf_code/ci4.dev/gitroot/ci4/application/Config/Database.php
Reply
#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




Theme © iAndrew 2016 - Forum software by © MyBB