Choosing a good PHP frameworks can help you develop complex Rich Internet Applications quickly, with a best practices oriented approach, and saving a lot of time reusing code snippets that are already available. There are a lot of interesting PHP frameworks you can choose for your next web project. Today we will focus on one of my favorite PHP Frameworks: CodeIgniter.
CodeIgniter is a powerful, high-performance, open-source PHP framework that helps you author PHP applications rapidly. CodeIgniter is known for having a light footprint, there by reducing your server’s work.
In today’s post will attempt to show you the basics of setting up the CodeIgniter framework, including step by step tutorials showing you how to build awesome applications that uses the MVC approach the easy way.
1. Why CodeIgniter?
The simplicity of setting things up and getting an actual webpage that processes something online is quite easy. CodeIgniter uses the MVC or Model View Controller architectural pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.
CodeIgniter has probably the best definition of each the model, view, and controller.
- - The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your your database.
- - The View is the information that is being presented to a user.
- - The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page. The controller is the top level file for each page that allows you to include database requests in the form of ‘Models’ and templates as ‘Views’.
By using this practice your code is tidy and re-usable.
Source: Get started with CodeIgniter
2. Installing and Configuring CodeIgniter
First you need to download CodeIgniter from http://www.codeigniter.com/.
- 1. Unzip the package.
- 2. Rename the “CodeIgniter” folder to your application name “app”. Upload the CodeIgniter folders and files to your PHP and MySQL enabled server. Normally the index.php file will be at your root.
- 3. Open the application/config/config.php file with a text editor and set your base URL.
$config['base_url'] = "http://localhost/app/";
- 4. If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.
$db['default']['hostname'] = "localhost"; $db['default']['username'] = "root"; $db['default']['password'] = "root"; $db['default']['database'] = "helloworld"; $db['default']['dbdriver'] = "mysql";
This code connects to a MySQL database called “helloworld” on a localhost with the username “root”, and the password, “root”.
Please visit this tutorial to show you the basics of setting up the framework, including how to build a basic hello world application that uses the MVC approach.
3. Building Your First CodeIgniter Application
Creating web applications with CodeIgniter (CI) is quick and easy because CI handles a lot of the typical application requirements right out of the box (like session management, database abstraction and file uploading). And while CodeIgniter does handle the repetitive stuff it’s still up to you to create a scalable and easy to update application.
You will need to check the following Step By Step Tutorial to learn how to create your first CI application:
- Building Applications using CodeIgniter Series: File Structure, Configuration, Helpers, Code Templates.
- Creating First Application at CodeIgniter
- Building a Database-Driven Application with the Code Igniter PHP Framework
- Easy Development With CodeIgniter
4. How to Create Awesome Applications Built with CodeIgniter
In this tutorial, we will learn how to build a RSS 2.0 Feed with the PHP framework CodeIgniter.
In this tutorial, we will learn how to generate PDF files with CodeIgniter and the R&OS library..
This tutorial will cover the new “Shopping Cart” Class. The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard “shopping cart” format, allowing the user to update the quantity or remove items from the cart.
In this series of tutorials we’ll be learning how to create a multi-gaming clan website with support for many different games, forums and a full admin system.
How to use the validation class included with this framework to develop a PHP program that can be used to check data submitted through some web forms.
This tutorial is about creating simple CodeIgniter + database + ajax system. User will be shown a form to post a message. Then after he/she press the submit button, the system will save the message using ajax and then show the message.
In this tutorial, we will learn how to create a search page with CodeIgniter and jQuery. We’re not gonna create only a default search page using CodeIgniter framework, but also a real time search with jQuery’s support.
This article demonstrates how to update our twitter status via the ‘Twitter API’ using CodeIgniter.
This tutorial will show you how to build a powerful web application for hosting images, using the flexibility of Codeigniter. This tutorial should teach you about the MVC coding philosophy, integral to producing serviceable applications.