Hello world program in php codeignter, CodeIgniter mvc example , code and explanation

Hello world program in php codeignter

By Yashwant Chavan, Views 6553, Date 03-Jun-2012

CodeIgniter is an open source web application framework. Its simple and easy to understand, it works on the MVC Pattern. Hello world CI program help you to understand the Controller, View and Project configuration details. Let see the step by step guide to write first hello world program

tags php php-codeigniter

Code Igniter Project setup.

Download codeigniter framework from codeigniter website Download Code Igniter Once the framework downloaded, Extract or unzip it into "\xampp\htdocs" folder with any project name.

Import CodeIgniter Project in Eclipse

Once you have downloaded CodeIgniter, In our case we use "CodeIgnitorTutorial" as project name. Refer the below project structure in Eclipse IDE

Code Igniter Folder Structure Significance

1]The config folder configuration folder. Which helps to configure database setting,Component Loading, Constant declaration etc.
2]The controllers folder stores all the controllers for the application.
3]The errors folder stores all the template error pages for the application. When any error occurs the error page is generated.
4]The helpers folder stores all the helpers which are specific to your application.
5]The hooks folder is for hooks which modify the functioning of Class core files
6]The libraries folder stores all the custom libraries which are specific to your application
7]The models folder stores all the models for the application.
8]The views folder stores all the views for the application.

Configuring CodeIgniter

Configure Application Base URL. To do this, open up system/application/config/config.php set the application URL

$config['base_url'] = 'http://localhost/CodeIgnitorTutorial';

welcome_message.php is the view file under /application/views/welcome_message.php folder

<!DOCTYPE html>
<html lang="en">
      <title>Welcome to CodeIgniter</title>
      <h1>Hello World !</h1>
      <div id="body">
         <p>Hello World</p>

Welcome.php is the controller file under /application/controller/Welcome.php folder

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Welcome extends CI_Controller
    public function index() // default Method
        $this->load->;view('welcome_message'); // load the welcome_message.php view

Test the CodeIgniter application using this URL http://localhost/CodeIgnitorTutorial


Hope you like this Php Codeigniter Hello World article :)



Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]