Archive for the ‘setup’ tag
Setting up Codeigniter with dynamic configuration variables – fit for development teams
When working in a team it is necessary to create dynamic configuration variables for Codeigniter so you can easily share code on development, staging and live servers.
For example, in the team, each developer connects to a common development server (called “localhost”). There is a password protected remote staging server so clients can access it in parallel to the live site (eg. http://client.domain.com). The live site also has a public domain (eg. www.domain.com). So we need 3 sets of “base_url” and “database” settings.
An improved .htaccess file to remove index.php in CI
A quick update of the .htaccess to remove the index.php, while still protecting the application folder.
The previous method I used meant having to add every real file or directory to the .htaccess to allow them to be accessed. The updated way checks if the requested file/directory exists and if need rewrites to the index.php.
If you need to protect more directories separate them with | i.e. application|modules
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Switching codeigniter profiler on/off globally
In my post regarding setting up codeigniter, I created a debug setting in /application/config/application.php
/* |-------------------------------------------------------------------------- | Debug |-------------------------------------------------------------------------- */ $config['debug'] = TRUE;
in the constructor of every controller I add
$this->output->enable_profiler($this->config->item('debug'));
Now all I have to do is change the value in the application config to enable/disable profiling globally
Setting up Codeigniter
After setting up several codeigniter based sites with dev/staging/production environments, I thought I’d write up the steps I undertake.
A overview of the steps are:
- Download CI and upload to hosting environment
- Rename ‘system’ directory
- Move ‘application’ directory to public accessible directory
- Upload and modify index.php
- Add .htaccess to remove index.php from URL’s
- Modify ‘config.php’ for domain and remove of index.php form URL’s
- Add ‘application.php’ specific config file
- Modify ‘database.php’ config for dev/staging/production
- Modify the autoload config for regularly used libraries, helpers and application config file