Home arrow PHP arrow Page 2 - Introduction to the CodeIgniter PHP Framework

Start using CodeIgniter - PHP

In this group of articles, Iíll be taking a close look at the main features bundled with the CodeIgniter PHP framework. With it, you can quickly build small to moderate object-oriented applications. Now, itís time to begin harnessing the real power of CodeIgniter. Ignite yourself and start reading now!

TABLE OF CONTENTS:
  1. Introduction to the CodeIgniter PHP Framework
  2. Start using CodeIgniter
  3. Activating support for MySQL databases
  4. Developing the first application with Code Igniter
By: Alejandro Gervasio
Rating: starstarstarstarstar / 52
August 13, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Obviously, the first step that you should take before using Code Igniter is installing its source files into your test web server. To do so, simply point your browser to the following url: http://codeigniter.com/downloads/. Download the ZIP file that contains these files.

Once you've accomplished this, unzip the package and upload its folders and files to a chosen directory of your web server. In my personal case, I saved it to a ď/codeigniter/Ē directory under the serverís root, but you may want to select a different location.

Finally, navigate to the application/config/config.php file, then open it with your code editor and configure the following array settings, as shown below:


|--------------------------------------------------------------------------

| Base Site URL

|--------------------------------------------------------------------------


$config['base_url'] = "http://127.0.0.1/codeigniter/";



|--------------------------------------------------------------------------

| Index File

|--------------------------------------------------------------------------


$config['index_page'] = "index.php";



|--------------------------------------------------------------------------

| Default Language

|--------------------------------------------------------------------------


$config['language'] = "english";



|--------------------------------------------------------------------------

| Default Character Set

|--------------------------------------------------------------------------


$config['charset'] = "UTF-8";



|--------------------------------------------------------------------------

| Cache Directory Path

|--------------------------------------------------------------------------


$config['cache_path'] = 'http://127.0.0.1/codeigniter/cache/';



|--------------------------------------------------------------------------

| Session Variables

|--------------------------------------------------------------------------


$config['sess_cookie_name'] = 'ci_session';

$config['sess_expiration'] = 7200;

$config['sess_encrypt_cookie'] = FALSE;

$config['sess_use_database'] = FALSE;

$config['sess_table_name'] = 'ci_sessions';

$config['sess_match_ip'] = FALSE;

$config['sess_match_useragent'] = TRUE;

$config['sess_time_to_update'] = 300;



|--------------------------------------------------------------------------

| Global XSS Filtering

|--------------------------------------------------------------------------


$config['global_xss_filtering'] = FALSE;



|--------------------------------------------------------------------------

| Output Compression

|--------------------------------------------------------------------------


$config['compress_output'] = TRUE;



|--------------------------------------------------------------------------

| Rewrite PHP Short Tags

|--------------------------------------------------------------------------


$config['rewrite_short_tags'] = FALSE;


As you can see, the above settings provide Code Igniter with crucial information about your web applications, including the base url of your site, the default language and character set, and the index file that will be utilized. Also, itís possible to specify whether any output generated by an application should be filtered to prevent XSS attacks, and whether it should be cached and compressed previously.

Finally, thereís a number of simple options that tell Code Igniter how to handle session data. They are actually fairly easy to configure. Although, you should pay special attention to the following entries:


$config['sess_use_database'] = FALSE;

$config['sess_table_name'] = 'ci_sessions';


If a value of ďTRUEĒ is assigned to the first array element, then Code Igniter will store all of your session data in a MySQL database table, whose name will be specified in the second entry. In this case, a FALSE value has been assigned to the first setting, meaning that session data will be saved to a temporary directory in the web server.

Lastly, itís possible to configure whether the use of short PHP tags will be enabled within view files. This is something that will be discussed in more detail when I develop some sample applications for you. For now, Iíll keep this option disabled.

So far, so good. I showed how to configure the main entries of Code Igniterís config.php file. Of course, when you edit the file in question, youíll see that it contains a few additional settings. However, to keep things rather simple, Iím going to use only the ones discussed above.

Now that the ďconfig.phpĒ file has been properly setup, itís time to move on and learn how to configure an additional file, which is located at /config/database.php and is used by Code Igniter when working with MySQL databases.

To see how this database file will be edited, please click on the link below and read the following section.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: