PHP
  Home arrow PHP arrow Page 2 - Introduction to the CodeIgniter PHP Framework
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Introduction to the CodeIgniter PHP Framework
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 29
    2008-08-13


    Table of Contents:
  • Introduction to the CodeIgniter PHP Framework
  • Start using CodeIgniter
  • Activating support for MySQL databases
  • Developing the first application with Code Igniter

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Introduction to the CodeIgniter PHP Framework - Start using CodeIgniter
    ( Page 2 of 4 )

    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
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek