How to create template system layouts in CodeIgniter 2.0

Templating in CodeIgniter, it’s mean we should make your own layouts system. If you have using CakePHP before, then you see there no automatic templating views in CodeIgniter. After searching and compare with anothers, i get Philsturgeon template is near with CakePHP template system ( http://getsparks.org/packages/template/show ).

So, first step, download and install it. See the installation guide to make your step easier. I assume you have installed the template into your CodeIgniter successfully. I load this template system in autoload.php [cci lang="php"]$autoload['libraries'] = array(‘database’,'session’,'template’);[/cci].
Continue reading

NGINX configuration for CodeIgniter 2.0

This is my NGINX configuration for running CodeIgniter 2.0.


server {

listen 80; ## listen for ipv4

server_name ci;
root /your-public-html;
access_log /var/log/nginx/yourdomain.access.log;
error_log /var/log/nginx/yourdomain.error.log;

# If file is an asset, set expires and break
location ~* \.(ico|xml|gz|xml.gz|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
break;
}

location / {
index index.php index.html index.htm;

if (-f $request_filename) {
expires 30d;
break;
}

if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?$1 last;
break;
}

}

location ~ \.php$ {
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /your-public-html/$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}

@kudos to Buclar :
If you get some problem, then you should set uri_protocol to $config['uri_protocol'] = ‘REQUEST_URI’;

Solving RSS Feed error in Codeigniter 2.0

There are several commmon error when building RSS Feed in CodeIgniter 2.0. Somehow we made mistakes and here are top list case.

When we got [cci lang="php"]ErrorException [ Parse Error ]: syntax error, unexpected T_STRING[/cci], this happen because you have PHP short_tags enabled, which means [cci lang="php"]

To fix this, turn off short_tags in php.ini or code like this :

‘; ?>

Another problem is [cci lang="php"]Line Number 1, Column 2: [/cci]. This usually happen because we close our documents with [cci lang="php"]?>[/cci] php tags. In CodeIgniter, we should leave our end of file without using [cci lang="php"]?>[/cci].

So, when you facing another RSS Feed error, try to check your php.ini and use CodeIgniter code behaviour.

Solve blank page URL Rewrite CodeIgniter in Subfolder using .htaccess

When we place CodeIgniter as subfolder in localhost environment, it will have some problem with URL rewrite. For example, i have http://localhost/codeigniter. So, if we using default tutorial on CodeIgniter without carefully then it will throw us into “blank page” and without any error.

Configuring Codeigniter for subfolder is easy. Here the steps :

1. Create .htaccess at root instalation folder
Continue reading

How to use Zend Framework in CodeIgniter 2.0

Combine Zend Framework with Codeigniter will give great result and cutting development time. Intergrating Zend Framework into CodeIgniter 2.0 is very easy. First, you download new Zend Framework here . After downloading, unpack it package and get Zend folder. Put this Zend folder into app/libraries in CodeIgniter.

Then, we create Zend libraries :
Continue reading