CodeIgniter Tutorial – CodeIgniter Explained

What will you learn?

1. What is a PHP Framework?

2. What is CodeIgniter?

3. What is MVC?

4. MVC Pattern

5. Why CodeIgniter?

What is a PHP Framework?

First of all, what is PHP? I’d say that PHP (Hypertext Preprocessor) is the best scripting language at this moment, even if is exactly 15 years old. PHP is able to create dynamic webpages interpreted by a webserver (Apache, Lighttpd, nginx, etc), but also can create GUI applications.

This is enough for you right now, if you need more details check these links:

If you already know what is PHP we have to move on. If you’re already a PHP programmer, I think you know that some parts of your code are duplicated. So this is the moment to find out what is a PHP Framework.

A PHP Framework is a collection of pre-written methods and classes, that are already secured, optimized, well documented and ready to use anytime, “out of the box”.

What is CodeIgniter?

As you maybe think, CodeIgniter is a PHP Framework for PHP 4 and PHP 5 in the same time. CodeIgniter’s main goal is to allow user to develop lightning fast applications, without writing your code from zero. So you already have a basic package, with everything what’s needed to write a kick-ass application.

What is MVC?

MVC (Model-View-Controller), is an architectural pattern used in almost all programming and scripting languages, including PHP.

The Model – usually is used to connect with the database, making CRUD operations (Create, Read, Update, Delete)

The View – most of the time, here you will print the data received from your controller, and other HTML markup. Basically, a view is every page you see over the internet.

The Controller – is responsible to handle the requests, manipulating models or other controller. Try to keep the controller as simple as possible.

MVC Pattern

So, let me explain it a bit. There would be 5 steps:

1. Your computer will send a request to the Controller

2. The Controller will interact with the Model, making a demand.

3. The Model will make the processing, then return some data to the Controller.

4. The Controller will analyze the results (maybe needs some more data, and it will make another request to another Model).

5. Finally, the data will be sent to the view, which is interpreted by the webserver, and will be displayed back in your browser.

Let’s take an example over a registration page.

1. You enter on the registration page, complete the fields and click Submit.

2. The request is send to the controller, it will ask the model about your identity.

3. The model analyze the data you sent (if you are already a member, if your data is correct, etc.) and it will send an Accept or a Denial back to the controller.

4. The Controller will analyze the Accept/Denial from the model, and will decide what to do.

5. Finally, it will send “a Welcome” to the view, which will be visible to you as a Welcome page, or an error page.

Why CodeIgniter?

First of all, CodeIgniter has the MVC architecture. So your application will be organized as I’ve already explained.

Is very easy to learn, as it’s deeply documented and very easy to extend.

CodeIgniter is a very light PHP framework (2.1 MB including the entire documentation) compared with:

1. Zend Framework 1.10.2 Full – 24 MB

2. symfony 1.4.3 – 5.1 MB

3. CakePHP 1.2.6 – 4.5 MB

Is lightning fast compared with other PHP Framework, I think it’s the fastest PHP framework.

The installation process is very very easy, you only need to unpack latest stable version, upload it on your host ,simply set ONE parameter and you are done. If course if you need something more, you have a few config variables. We’ll talk about the installation is a future tutorial.

CodeIgniter doesn’t have a command line tool like CakePHP or symfony. Maybe some users will like the command line tool, because it will generate your models, views and controller and other stuff, but honestly I feel I am losing the control of such an application. Not everytime you will need a model or a view for your controller, so why generate them?

Maybe you were wondering “Why other frameworks are so big?”. Most of the frameworks have included in their core additional libraries (authentication, captcha, currency, feed, ajax, connection with webservices – Twitter, Flickr etc.), Object Relationship Mapper (we’ll talk about ORM in next tutorials) and other. A normal projects doesn’t need everything I’ve listed, so “why pay for what you don’t need”?

And I forgot to say, that CodeIgniter and other PHP Frameworks listed here are Open Source, so you can use them for free and modify then as you wish. There is a bunch of libraries, helpers and other open source software built on CodeIgniter.

Another thing I like to CodeIgniter is the way they help me building my links. What can you do when you want to move your application to another domain? Do you use relative paths to your files?

Do you create links with your domain everywhere and then mass-edit? Here CodeIgniter will help you with 2 methods: base_url() and site_url().

Both methods return the main URL for your application, but there’s a small difference between them, you’ll learn about this later. Let’s say you have your script installed on your-domain.com/my_blog, base_url() will return you exactly your URL.

CodeIgniter has also a fantastic form validation library, which helps you validate your data easily, before making database operations.

Sending emails has never been easier. CodeIgniter even has an email class for you. Do you want to send an email? Ok, here is the code:

Ever wondered if you could visualize your website in 3D? Well, here’s one such Firefox extension that allows you to do so. Tilt is a Firefox add-on that lets you visualize any web page DOM and provides the relationship between various parts of a website in 3D.

User Interface Design in C# Windows Form Application From Scratch In this C Sharp tutorial you will learn user interface design in C# application. This step-by-step tutorial will help you deeply understand…

In this second part article you will learn how to build an image gallery that will load images from a web server. I decide to call it “Intelligent” because you don’t need to configure any XML or flash file. Just put the Flash movie and the images on a server and they will be loaded automatically. Nice ah?

There are many popular open source tweening engines in the Flash community today. Numbered among these are Tweener, TweenLite/Tweenmax, Tweensy, and GTween. This is a short look at the capabilities of newcomer to the scene: BetweenAS3. BetweenAS3 is the tweening engine brainchild of Yoshihiro (yossy) Shindo and is available as part of the Spark project (i.e. it is brought to us by one of the same group that brought the world the FLARToolkit for Augmented Reality in Flash and countless other goodies).

In this article you will learn how to build an image gallery that will load images from a web server. I decide to call it “Intelligent” because you don’t need to configure any XML or flash file. Just put the Flash movie and the images on a server and they will be loaded automatically. Nice ah?

Today we start a 9 part tutorial series on creating a Shoot’em’Up game. We will cover all the necessary topics to create it from scratch, which will help you to understand and apply these guidelines to other projects. Ath this first part. we look at getting the Away3D engine up and running by creating a UIComponent that will contain and initialize the necessary Away3D components.

Flash it’s a powerful application and can be really complex, but even beginners can create a cool menu for demonstration or for use in a personal site. The menu that we will create is simple, but the swirl animation is something that you don’t see everywhere, for that I’ve decided to explain one way to make an animation of growing swirls without any Action Script code.You will also learn how to import artwork from illustrator where I’ve pre-made the graphics, the work is very simple and the result will be very cool.

Possibly the hottest thing to hit the Flash community since the advent of several excellent 3D engines is the recent debut of 3D physics engines. Here we’ll examine a way of using one of the more popular 3D engines, JiglibFlash, in conjunction with the prominent 3D engine Papervision3D to create a bowling game.

In this tutorial you will learn how to build an accordion style menu from scratch that can be configured by using an external file.

The menu items can bet totally configured in XML with label and can load text, image or swf on it’s open “state”. Just follow the tutorial, it’s quite simple. At the end you will see a secon example achieved by this procedure.

CodeIgniter not having an ORM really bothers me, however, I have resolved that problem with an “Overzealous” Data Mapper (http://www.overzealous.com/dmz/) that was built for CodeIgniter. In my opinion, it is a great way to access the data and still allow me to use everything else I like about CodeIgniter.

Also, since I like to separate my PHP from my HTML, I use Smarty templates to make a much cleaner view, again in my opinion.

I know PHP some and i have heard about codeigniter many times by my friends but never gave so much emphasis.The information you provide above is quite helpful and it made my vision somewhat more clear .Thanks for the information