Codeigniter One of the best PHP framework

Nov 27, 2015

Alphanso Tech

Php

0

Codeigniter One of the best PHP framework

Codeigniter is one of the popular and widely used framework out of many php based MVC frameworks. It has small footprint, minimalist architecture and fewer resources to load which makes the framework lighter and faster than it’s competitors.

Yes, we know the downside of singleton architecture it’s following, but the next major release i.e codeigniter 4 will be written ground up completely. It will eliminate the singleton pattern and will be based on the PHP 7! interesting isn’t it?

If you are working on mid scale web application project or you are a beginner to intermediate developer looking for a web development framework which is fast and easy to learn, I would recommend you have a look at codeigniter development framework.

If you are familiar with MVC concept, oop and basics of PHP you are good to go for your first MVC based web application using codeigniter.

If you want to jump start into the code igniter development, well we have this article for you guys.

The article will explain:

In this blog we will cover up following topics:

  1. What is MVC?
  2. Codeigniter structure architecture.
  3. Create a static program with controller and view.
    1. Installation of Codeigniter
    2. Basic configuration
    3. Attach database with Codeigniter.
  4. Interaction with model & view.
  5. Some basic Instruction regarding CI.

What is MVC?

MVC Architecture

MVC Architecture

Model

Responsible for maintaining data.

Contains Business Logic.

View

Responsible for displaying all or a portion of the data to the user.

Does not store any data except to cache state.

Controller

Responsible for interactions between the Model and View.

Updates the view when the model changes


Codeigniter structure architecture

Let’s study the basic structure and architecture by taking an example of User Registranion.

CI basic Architecture

CI basic Architecture

Codeigniter One of the best PHP framework ,It was built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.


 

Create a static program with controller and view

  • Installation Of CodeIgniter

Installation of CodeIgniter is quite simple. Just navigate Codeigniter official site,you will get the Download link.

  • Download the CodeIgniter latest version.
  • Extract the downloaded file and put it in your server folder Apache24/htdocs or Xampp/htdocs,vice versa.
  • Set base url at application/config/config.php i.e. $config[‘base_url’] = ‘http://localhost/ci/’.
  • Goto browser and run CI.
  • Attach database with Codeigniter

Attachment of database in CI is very easy.

  • Explore the CI structure.
  • Navigate to application/config/database.php.
  • At the bottom of the page you will get an array named $db.
  • Assign the host name, user name,password and the database name. Now your database has been connected with CI.

Now navigate to application/controller/, Create new file here, with any name it will be your controller.

Note : The name of Controller should be starts with Capital letter.

application/controller/firstcontroller.php

While, working under MVC ,Open any file in browser you don’t need to call certain page, in place call the contraller, A controller has multiple methods and they act as an individual page.

In our case we can call our controller like following

localhost/start_ci/index.php/firstcontroller/index

Interaction with model and view

consider following case represents the student info.

Create Table

 

1.Create a model

application/model/Student_model.php

Note : Make sure the name of model and class should be same.

2.Create a controller

application/controller/Student_controller.php

3.Create a view

application/view/student_list.php

Some basic Instruction regarding CI

Use of .htaccess

execute ci on browser

localhost/start_ci/index.php/firstcontroller/

to remove index.php from url you need to write following code in .htaccess

Use of autoload

localhost/start_ci/index.php/autoload.php

In this file you can load helper functions, codeigniter built in libraries,database etc so that no longer need to load them individually in every page.

I hope you will find this post very useful regarding CodeIgniter. Let me know any questions if you have in comment regarding WordPress. I will reply you ASAP.

 

Looking for CODEIGNITER/PHP consultation?

CONTACT US for free consultation

Post by Alphanso Tech

Created in 2009, Alphanso Tech is a leading IT Consulting company with a presence in the USA, Canada, and India.We are a trusted and leading service provider to many top-tier companies in the area of Custom WordPress Development , Web Application Development , iOS App Development , Outsourcing Services, Online Marketing and many other related activities.

Leave a Reply

Your email address will not be published. Required fields are marked *