https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_b964594d3d957944241961017b9eb19bf02834de44cce93d8e67dd306852dbe346167181e455e33d5268ea01d973d77bb056848546f31794f31a4c31a9da5aa3.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_23f1ae74c634d7e5e0a067c22b7a8c2d79c3ffd9a3b9395fc82c1b3b99635552b994f1f72f532f28ceaff1ea054ea026cd488cd62fa03a4ad91d212b5f3c5a72.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_451c3884f51125f7687e5bb07cfab033c04cb7174c33f93213b2af4bad2af13cf48b92a7fa95fc86d7d436f355938a3ac50aa119cdb7c9b6d5a52815c3e6033e.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bfff9e63e857e9ee612e292d4a6edf3ced64d6a756925c953a9d8f77845ff601eca64d73dfa48756b1a9f4a4d6de6127a273bcde16ddeb71a22383460f4e94b0.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f4dd7e1d73ae5eda35ed5ad6aa965b612dbf483ece3ca50c1e8e30ad8dff1c66a160ed75e958e2db399661d229874783e0834ad813a479437035666b8e9e3386.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_4fce0769137d4cd096989b0349bc3c2bbfca79ac311fdf714c41ab24d87551c7b49b756c8a8de090b0714a0ad0560e49fa532ba5a88875ea4afd78efac464df6.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_85cec8b07d60426b11040e471babca0d2f9c8dc87a9b56e06cad39828f7f67179e29609100f282a574872c9a93fb635b25416300eb4c97bc5a653d00cf6f8dbf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_6768e5a27d4d357347338621c0d20bd269b126d30eec796193390f2f530fbaea60af84130c46f9786114be65149e661e87d55c339219c90aa76396d7e5b734ef.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_2acd6bdff3b680341e8c727da5169a647123eb8fd0a90253161b4c3af272c15d293bf9bb217008bb13f84d1910b0e166798001f8603b6c026d5c20a76c41d47c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_ebc6f29b6b21fa542abb217dd32a5516127834bd6469831295d3a2f0fad0b113ec7216befdf7216ea6c528989cacea8b42e3a55cef28ee013251eb5483da1588.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_268c9bba6ba649318f0da28c37b09a9bbfa371210f9b6b52faa7fd8ae94abf6b3c3bfeb5df5705c93495ce1152ca58aeabc435d6c6c1bd959025165c3f50e086.js
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Featured
    • Advanced Python Topics
    • AWS Learning Roadmap
    • JWT Complete Guide
    • Git CheatSheet
  • Explore
    • Programming
    • Development
      • microservices
      • Front End
    • Database
    • DevOps
    • Productivity
    • Tutorial Series
      • C# LinQ Tutorials
      • PHP Tutorials
  • Dev Tools
    • JSON Formatter
    • Diff Checker
    • JWT Decoder
    • JWT Generator
    • Base64 Converter
    • Data Format Converter
    • QR Code Generator
    • Javascript Minifier
    • CSS Minifier
    • Text Analyzer
  • About
  • Contact
CodeSamplez.com

CodeSamplez.com

Programming And Development Resources

You are here: Home / Development / Codeigniter Tutorial For Beginners: PHP Web Application Guide

Codeigniter Tutorial For Beginners: PHP Web Application Guide

Updated May 24, 2025 by Rana Ahsan 50 Comments ⏰ 14 minutes

codeigniter tutorial for beginners

Are you looking to build powerful PHP web applications but feeling overwhelmed by where to start? Well, I’ve got fantastic news for you! Codeigniter is absolutely the framework you need to master. I’ve been using it for years, and I can tell you firsthand that it’s one of the most beginner-friendly yet powerful PHP frameworks out there.

In this comprehensive tutorial, I’ll walk you through everything you need to know to start building amazing web applications with Codeigniter 4, the latest version as of now. No confusing jargon, just straightforward guidance that’ll have you coding like a pro in no time.

What Makes Codeigniter So Special?

Before we dive into the code, let me tell you why Codeigniter stands out from other PHP frameworks:

  • Lightning Fast: Codeigniter is incredibly lightweight and performs much faster than most other frameworks.
  • Easy Learning Curve: The documentation is superb, and the framework follows logical patterns that are easy to grasp.
  • Zero Configuration: You can set up and start developing with minimal configuration.
  • Built-in Security: The framework comes with powerful tools to protect your applications from common web attacks.
  • Community Support: A massive community means you’ll never get stuck on a problem for long.

Trust me, once you start using Codeigniter, you’ll wonder how you ever developed without it!

Prerequisites

Before we begin, make sure you have:

  1. Basic knowledge of PHP (you should understand variables, functions, and object-oriented concepts. Explore our PHP Tutorials to level up your skill!)
  2. Understanding of the MVC design pattern (I’ll explain this more as we go)
  3. A local development environment (XAMPP, WAMP, or similar)
  4. PHP 8.1 or higher installed
  5. Composer installed (the PHP dependency manager)

Understanding MVC Architecture

MVC(Model View Controller) Web Application Architecture Pattern Diagram

Codeigniter uses the Model-View-Controller (MVC) pattern, which separates your application into three interconnected components:

  • Models: Handle your data and business logic
  • Views: Display information to users
  • Controllers: Process user requests and coordinate between models and views

This separation makes your code more organized, easier to maintain, and simpler to test. You’ll absolutely love how clean your codebase becomes!

Installing Codeigniter 4

Let’s get started by installing Codeigniter 4. There are two ways to do this:

Method 1: Using Composer (Recommended)

Open your terminal or command prompt and run:

composer create-project codeigniter4/appstarter my-project

This creates a new Codeigniter project named “my-project” in the current directory.

Method 2: Manual Download

  1. Download the latest version from Codeigniter’s official website
  2. Extract the files to your web server’s root directory
  3. Rename the directory to your project name

I strongly recommend using the Composer method as it makes updating Codeigniter much easier in the future.

Directory Structure

After installation, you’ll see the following directory structure:

my-project/
├── app/
│   ├── Config/
│   ├── Controllers/
│   ├── Models/
│   ├── Views/
│   └── ...
├── public/
├── system/
├── writable/
├── tests/
└── vendor/Code language: PHP (php)

Let’s understand what each important directory does:

  • app: This is where all YOUR code goes – controllers, models, views, config files, etc.
  • public: The only directory that should be publicly accessible. Contains index.php and assets like CSS, JS, and images.
  • system: Core framework files – NEVER modify these files directly!
  • writable: Contains files that need write access (logs, cache, etc.)
  • vendor: Contains third-party dependencies

Basic Configuration

Before we start building, let’s configure a few basics:

1. Environment Setup

Rename the env file to .env in your project root. Open it and set:

CI_ENVIRONMENT = development

This enables detailed error reporting during development.

2. Database Configuration

In the .env file, configure your database settings:

database.default.hostname = localhost
database.default.database = my_database
database.default.username = root
database.default.password = your_password
database.default.DBDriver = MySQLiCode language: PHP (php)

3. URL Configuration

Still in the .env file, set your base URL:

app.baseURL = 'http://localhost/my-project/public/'Code language: JavaScript (javascript)

Creating Your First Controller

Controllers are the heart of your application, handling user requests and providing responses. Let’s create our first controller:

  1. Create a file named Blog.php in the app/Controllers directory:
<?php

namespace App\Controllers;

class Blog extends BaseController
{
    public function index()
    {
        echo "Hello World! Welcome to my blog.";
    }
}Code language: HTML, XML (xml)

Now, start your local server and navigate to http://localhost/my-project/public/blog. You should see “Hello World! Welcome to my blog.” This simple controller demonstrates how easy it is to create pages in Codeigniter! 🎉

Tip💡: Explore All CodeIgniter Tutorials by CodeSamplez.com

Working with Views

Displaying raw text isn’t very useful. Let’s create a view to render HTML properly:

  1. Create a directory app/Views/blog
  2. Create a file index.php in this directory:
<!DOCTYPE html>
<html>
<head>
    <title>My Awesome Blog</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            color: #333;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }
        .article {
            margin-bottom: 30px;
            border-bottom: 1px dashed #ccc;
            padding-bottom: 20px;
        }
        .article h2 {
            margin-bottom: 5px;
        }
        .meta {
            color: #777;
            font-size: 0.9em;
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
    <h1>Welcome to My Blog</h1>
    
    <?php foreach($articles as $article): ?>
        <div class="article">
            <h2><?= $article->title ?></h2>
            <div class="meta">By <?= $article->author ?></div>
            <p><?= $article->content ?></p>
        </div>
    <?php endforeach; ?>
</body>
</html>Code language: HTML, XML (xml)
  1. Now, update your controller to use this view:
<?php

namespace App\Controllers;

class Blog extends BaseController
{
    public function index()
    {
        // Data to be passed to the view
        $data = [
            'articles' => [
                (object)[
                    'title' => 'Getting Started with Codeigniter 4',
                    'author' => 'John Doe',
                    'content' => 'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'
                ],
                (object)[
                    'title' => 'MVC Pattern Explained',
                    'author' => 'Jane Smith',
                    'content' => 'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'
                ]
            ]
        ];
        
        // Load the view with data
        return view('blog/index', $data);
    }
}Code language: HTML, XML (xml)

When you refresh the page, you’ll see a nicely formatted blog with two articles. That’s the power of views – they separate your HTML from your PHP logic!

Creating a Model

Models handle your data operations. Let’s create a model to manage our blog articles:

  1. Create a file named BlogModel.php in the app/Models directory:
<?php

namespace App\Models;

use CodeIgniter\Model;

class BlogModel extends Model
{
    // In a real application, you'd connect to a database
    public function getArticles()
    {
        // For now, we'll return dummy data
        return [
            (object)[
                'title' => 'Getting Started with Codeigniter 4',
                'author' => 'John Doe',
                'content' => 'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'
            ],
            (object)[
                'title' => 'MVC Pattern Explained',
                'author' => 'Jane Smith',
                'content' => 'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'
            ],
            (object)[
                'title' => 'Working with Databases in CI4',
                'author' => 'Mike Johnson',
                'content' => 'Codeigniter makes database operations simple with its powerful database library.'
            ]
        ];
    }
}Code language: HTML, XML (xml)
  1. Update your controller to use this model:
<?php

namespace App\Controllers;

use App\Models\BlogModel;

class Blog extends BaseController
{
    public function index()
    {
        // Create an instance of the model
        $model = new BlogModel();
        
        // Get data from the model
        $data = [
            'articles' => $model->getArticles()
        ];
        
        // Load the view with data
        return view('blog/index', $data);
    }
}Code language: HTML, XML (xml)

Working with a Real Database

Now let’s upgrade our model to use a real database:

  1. Create a database table:
CREATE TABLE articles (
    id INT(11) PRIMARY KEY AUTO_INCREMENT,
    title VARCHAR(255) NOT NULL,
    author VARCHAR(100) NOT NULL,
    content TEXT NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO articles (title, author, content) VALUES
('Getting Started with Codeigniter 4', 'John Doe', 'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'),
('MVC Pattern Explained', 'Jane Smith', 'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'),
('Working with Databases in CI4', 'Mike Johnson', 'Codeigniter makes database operations simple with its powerful database library.');Code language: PHP (php)
  1. Update your model to use the database:
<?php

namespace App\Models;

use CodeIgniter\Model;

class BlogModel extends Model
{
    protected $table = 'articles';
    protected $primaryKey = 'id';
    protected $allowedFields = ['title', 'author', 'content'];
    protected $useTimestamps = true;
    protected $createdField = 'created_at';
    protected $updatedField = 'updated_at';
    
    // No need for a custom getArticles method - we can use the built-in findAll()
}Code language: HTML, XML (xml)
  1. Update your controller:
<?php

namespace App\Controllers;

use App\Models\BlogModel;

class Blog extends BaseController
{
    public function index()
    {
        $model = new BlogModel();
        
        $data = [
            'articles' => $model->findAll()
        ];
        
        return view('blog/index', $data);
    }
}Code language: HTML, XML (xml)

That’s it! Codeigniter’s model system makes database operations incredibly simple. You get all the CRUD (Create, Read, Update, Delete) operations without writing a single SQL query!

Creating Forms and Handling Input

Let’s add functionality to create new blog posts:

  1. Create a new view app/Views/blog/create.php:
<!DOCTYPE html>
<html>
<head>
    <title>Create New Article</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            color: #333;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"], textarea {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
        }
        textarea {
            height: 150px;
        }
        button {
            background: #4CAF50;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <h1>Create New Article</h1>
    
    <?php if(session()->getFlashdata('error')): ?>
        <div style="color: red; margin-bottom: 15px;">
            <?= session()->getFlashdata('error') ?>
        </div>
    <?php endif; ?>
    
    <form action="<?= site_url('blog/store') ?>" method="post">
        <div class="form-group">
            <label for="title">Title</label>
            <input type="text" name="title" id="title" required>
        </div>
        
        <div class="form-group">
            <label for="author">Author</label>
            <input type="text" name="author" id="author" required>
        </div>
        
        <div class="form-group">
            <label for="content">Content</label>
            <textarea name="content" id="content" required></textarea>
        </div>
        
        <button type="submit">Create Article</button>
    </form>
    
    <p><a href="<?= site_url('blog') ?>">Back to Articles</a></p>
</body>
</html>Code language: HTML, XML (xml)
  1. Add methods to your controller:
// In Blog.php controller

public function create()
{
    return view('blog/create');
}

public function store()
{
    // Validate input
    $rules = [
        'title' => 'required|min_length[3]|max_length[255]',
        'author' => 'required|min_length[3]|max_length[100]',
        'content' => 'required|min_length[10]'
    ];
    
    if (!$this->validate($rules)) {
        return redirect()->back()->withInput()->with('error', $this->validator->getErrors());
    }
    
    // Get form data
    $data = [
        'title' => $this->request->getPost('title'),
        'author' => $this->request->getPost('author'),
        'content' => $this->request->getPost('content')
    ];
    
    // Save to database
    $model = new BlogModel();
    $model->insert($data);
    
    // Redirect to blog list
    return redirect()->to('/blog')->with('message', 'Article created successfully!');
}Code language: PHP (php)
  1. Add a link to the create page in your index view:
<!-- Add this near the top of app/Views/blog/index.php -->
<p><a href="<?= site_url('blog/create') ?>">Create New Article</a></p>

<!-- And add this to display success message -->
<?php if(session()->getFlashdata('message')): ?>
    <div style="background: #d4edda; color: #155724; padding: 10px; margin-bottom: 20px;">
        <?= session()->getFlashdata('message') ?>
    </div>
<?php endif; ?>Code language: HTML, XML (xml)

Routes

Codeigniter 4 offers powerful routing capabilities. Let’s configure some routes to make our URLs cleaner:

  1. Open app/Config/Routes.php and add:
$routes->get('blog', 'Blog::index');
$routes->get('blog/create', 'Blog::create');
$routes->post('blog/store', 'Blog::store');
$routes->get('blog/(:num)', 'Blog::show/$1');Code language: PHP (php)

This allows URLs like:

  • http://localhost/my-project/public/blog for the index
  • http://localhost/my-project/public/blog/create to create an article
  • http://localhost/my-project/public/blog/1 to view article #1

Handling AJAX Requests

Want to add some interactivity? Here’s how to handle AJAX requests in Codeigniter:

  1. Add a new method to your controller:
public function like($id)
{
    // In a real app, you'd update a likes count in the database
    
    // For now, just return a response
    return $this->response->setJSON(['success' => true, 'likes' => rand(5, 100)]);
}Code language: PHP (php)
  1. Add some JavaScript to your view:
<!-- Add this to your index.php view, before the closing body tag -->
<script>
function likeArticle(id) {
    fetch(`<?= site_url('blog/like') ?>/${id}`)
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                document.getElementById(`likes-${id}`).textContent = data.likes;
            }
        });
}
</script>

<!-- And modify your article display to add a like button -->
<div class="article">
    <h2><?= $article->title ?></h2>
    <div class="meta">
        By <?= $article->author ?> | 
        <span id="likes-<?= $article->id ?>">0</span> likes
        <button onclick="likeArticle(<?= $article->id ?>)">Like</button>
    </div>
    <p><?= $article->content ?></p>
</div>Code language: HTML, XML (xml)

Using Helper Functions

Codeigniter comes with many helper functions to simplify common tasks. Let’s use some:

  1. Load helpers in your controller:
// In Blog.php controller constructor or method
helper(['form', 'url']);Code language: JavaScript (javascript)
  1. Now you can use helper functions in your views:
<!-- Instead of -->
<form action="<?= site_url('blog/store') ?>" method="post">

<!-- You can write -->
<form action="<?= site_url('blog/store') ?>" method="post">
    <?= csrf_field() ?> <em><!-- Adds CSRF protection token --></em>
    
    <!-- Form inputs here -->
    <?= form_submit('submit', 'Create Article', ['class' => 'button']) ?>
</form>Code language: HTML, XML (xml)

Adding Authentication

Most web applications need authentication. Let’s implement basic login/registration:

  1. Install the Shield authentication module (Codeigniter’s official auth solution):
composer require codeigniter4/shieldCode language: JavaScript (javascript)
  1. Run the migrations:
php spark shield:setup
php spark migrateCode language: CSS (css)
  1. Create a route group with authentication:
// In app/Config/Routes.php
$routes->group('admin', ['filter' => 'auth'], function($routes) {
    $routes->get('dashboard', 'Admin::dashboard');
    // Other protected routes here
});Code language: PHP (php)

This ensures only authenticated users can access the admin section!

Tips for Debugging

Codeigniter offers excellent tools for debugging your application:

  1. Enable debug toolbar by setting:
CI_ENVIRONMENT = development
  1. Use the debug bar to inspect:
    • Request and response data
    • Database queries
    • Performance metrics
    • Loaded files
    • And much more!
  2. For logging custom messages:
log_message('debug', 'This is a debug message');
log_message('error', 'Something went wrong!');Code language: JavaScript (javascript)

Common Pitfalls to Avoid

As you develop with Codeigniter, watch out for these common mistakes:

  • Forgetting namespaces: Always include the correct namespace for your models and controllers.
  • Direct model property access: Use getter and setter methods instead of direct property access:
// Incorrect 
$article->title = 'New Title'; 
// Correct 
$article->setTitle('New Title');Code language: PHP (php)
  • Not escaping output: Always use the esc() function to prevent XSS attacks: php<?= esc($article->title) ?>
  • Ignoring validation: Always validate user input before processing it.

Best Practices for Codeigniter Development

To get the most out of Codeigniter, follow these best practices:

  1. Use environment files: Keep sensitive data (like API keys) in .env files.
  2. Create Base Controllers: Extend BaseController for common functionality across controllers.
  3. Use Services: Leverage Codeigniter’s service system for dependency injection.
  4. Organize Business Logic: Keep heavy logic in models or services, not controllers.
  5. Use Migrations: Use database migrations for version control of your database structure.

Conclusion

Congratulations! You’ve now mastered the basics of Codeigniter development. This incredibly powerful framework makes PHP development faster, more secure, and much more enjoyable. From creating simple blogs to complex applications, Codeigniter has absolutely everything you need.

Remember, the best way to learn is by doing. Take what you’ve learned in this tutorial and start building your own projects. The more you practice, the more comfortable you’ll become with the framework.

And don’t forget – the official Codeigniter documentation is your best friend. It’s comprehensive, well-written, and updated regularly.

Happy coding with Codeigniter! If you found this tutorial helpful, please share it with others who might benefit from it.

Share if liked!

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket

You may also like


Discover more from CodeSamplez.com

Subscribe to get the latest posts sent to your email.

First Published On: May 2, 2011 Filed Under: Development Tagged With: codeigniter, php

About Rana Ahsan

Rana Ahsan is a seasoned software engineer and technology leader specialized in distributed systems and software architecture. With a Master’s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on programming and distributed systems concepts and help educate others.
Github | X | LinkedIn

Reader Interactions

Comments

  1. Chuck says

    November 21, 2011 at 10:51 AM

    First example works but the rest of the examples are lacking file names, etc. so not of much use as a beginner tutorial.

    Reply
    • Rana says

      November 21, 2011 at 11:50 AM

      Are you having issues? Can you please explain what? Then I can try to solve it and also update the tutorial for being more helpful for future seekers. Thanks..

      Reply
      • francis says

        September 21, 2014 at 10:21 PM

        Thanks for this…Like it

        Reply
    • as says

      July 2, 2015 at 3:11 AM

      Nice One. Thanks..

      Reply
    • talentedaamer says

      October 1, 2015 at 5:56 AM

      the name of the file should be similar to its class name,

      for example if we have a class blog the controller should be blog.php this way you will not get error.

      Reply
  2. Gokul Raj says

    November 21, 2011 at 11:58 PM

    How to create new controller.

    Reply
    • Rana says

      November 22, 2011 at 12:34 AM

      Hi, Please refer to “Create A Basic Controller” section. Please let me know f you don’t understand anything..

      Reply
      • Gokul Raj says

        November 22, 2011 at 1:06 AM

        Thanks Rana. Then i have another doubt how to create admin for cms. I created admin folder in controller. If i typed browser i have error page not found. What i do Rana.

        Reply
        • Rana says

          November 22, 2011 at 4:50 AM

          Hi, well, you will have to study a little about how codeigniter urls work and also how you can customize the routing. Seems like, you are facing issue similar to this one: http://stackoverflow.com/questions/8143997/codeigniter-2-0-x-controller-subdirectories-default-controller-needs-to-be-in . There is a solution already, refer to that. Hope these helps. Thanks.

          Reply
  3. suresh says

    December 28, 2011 at 5:00 AM

    that’s good

    Reply
    • MichaelB says

      January 1, 2012 at 5:43 PM

      The first section does work, then the rest of the article becomes unclear.

      1. In the section “Create a model”, what should be the filename of that file?
      2. In the section “Create A View”, what should be the filename of that?

      Reply
      • Rana says

        January 1, 2012 at 11:19 PM

        Hi MichaelB, There is no specific restriction to the naming convention for model/view(or even controller). You can use any name, just you will have to remember to extend them from their corresponding base class. Like, if you are creating a model, you must have to inherit the “CI_Model” class, to get the characteristics of a regular Codeigniter model. In case of view, just name the template any name and then call it from controller with data(if any), Like as follows:

        $this->load->view(“template_name”,$data);

        I will edit the tutorial for calling a view from controller. Seems it will may helpful to some other guys like you. Thanks for pointing out is.

        Reply
  4. ITGuy says

    January 18, 2012 at 3:00 PM

    Really great programming abilities you\’ve there. i\’m a programmer myself but I still require to learn until I reach your ability. great article!

    Reply
  5. best free web services says

    February 11, 2012 at 7:04 AM

    Wow, nice post buddy. It can help me to develop website using codeigniter framework.

    Reply
  6. Haider says

    February 18, 2012 at 2:58 AM

    thank you very much
    it give me complete inside out to the MVC as well as codeignighter
    thanks you very very much

    Reply
  7. kvkbharadwaz says

    February 22, 2012 at 10:04 AM

    this helped me a lot buddy and moreover your site interface is really good and CLEAN.

    keep up the good work.

    Reply
  8. bari says

    February 28, 2012 at 9:27 PM

    hi rana, i have problem with include php file. i use include(), require() and require_once(). but none of them works.
    i have a php file that contain only variables, so much variables. and i want to include the file to passing variables.
    how i supposed to do. pls help me.
    the ci directory:
    -application
    -system
    -user_guide
    -style
    -include_folder

    and my file in include_folder directory.

    thanks in advance.

    Reply
    • Rana says

      March 2, 2012 at 4:21 AM

      try using:

      APPPATH.”/include_folder/file_name.php”

      Reply
  9. balaji says

    April 2, 2012 at 1:00 AM

    it vary good for fresher + inretmideate

    Reply
  10. kamal says

    June 4, 2012 at 11:33 PM

    hello Rana,
    I’m a beginer in CI my problem is how to load jquery library in the current version of CI and how to apply a common CSS styling sheet to all my views

    Reply
  11. Jhon says

    June 25, 2012 at 12:07 AM

    Thanx Rana for providing these Tuts these are very useful for everyone especially fresher

    Reply
  12. pratik says

    July 26, 2012 at 10:55 PM

    great,i have one problem i want to pass the more then one query from the model and get in controller.now i want to some additional work on that query and pass to the view.how can i do that.thanks

    Reply
  13. john says

    August 12, 2012 at 9:24 AM

    Very useful especially on passing data to the view and how the keys of the associative array are automatically turned into variables in the view.

    Reply
  14. julieancordova says

    March 10, 2013 at 5:22 AM

    what would be the best IDE for code igniter?
    where I can use breakpoints,

    Reply
  15. Raza says

    May 30, 2013 at 2:43 AM

    the first program for blog.. throws an error more of a warnin. creating default object on empty value..

    Reply
    • Md Ali Ahsan Rana says

      May 30, 2013 at 3:52 AM

      Hello Raza, it seems like you php compatibility error. This exercize was written with php 5.3.x and you are probably using php 5.4 , right? Just initialize all the variables at first (example: $test = (object)NULL) solves the problem in most cases. If you are still not sure what to do, can you give the error line number or a screenshot link? Thanks.

      Reply
  16. Nadimuthu says

    November 29, 2013 at 9:57 AM

    How to configure with lamp? Anyone please help me..

    Reply
  17. Azhar says

    December 28, 2013 at 9:36 PM

    i have this problem. I have created a views/templates/navbar.php using bootstrap. the bootstrap is located in the root directory assets/bootstrap. I called the navbar.php through the default controller (news). It works.

    Then I create another views/templates/page.php. I created a function create_cosec in the default controller with $this->load->view(‘navbar’); and $this->load-view(‘page.php’); . I wish the page will display the navbar on the top follow by the page details.

    When I call the page localhost/index.php/news/ create_cosec ==>the page is display correctly but the navbar displayed but without the bootstrap functionalities. It seems that codeigniter doesn’t know where is the assets/bootstrap directory?

    Is it URL issues?
    Thanks

    Reply
  18. D R says

    May 12, 2014 at 3:44 PM

    Good framework to work with, also believe in learning the pure php language too, and also try to learn other frameworks so that you keep yourself on top of development.

    Reply
  19. Lucky Bhumkar says

    August 19, 2014 at 1:41 PM

    Good explanation..but lacks screenshots.

    Reply
  20. Michael says

    August 27, 2014 at 7:08 AM

    How about some explanation of the root folders like “Source files”… what other folders are at this level? I’m looking at it from a continuous deployment point of view.

    Reply
  21. mwamba says

    September 16, 2014 at 8:57 AM

    its giving error
    A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: models/blogmodel.php

    Line Number: 12

    in the list model

    Reply
    • Md Ali Ahsan Rana says

      September 16, 2014 at 9:01 PM

      That is because of php version, I assume. Should be fixed by using ‘$list = (object)NULL;’ . Hope this helps.

      Reply
  22. Lilly says

    January 30, 2015 at 3:06 AM

    Excellent Tutorial !! Helps alot.

    Reply
  23. bakhtiar khan wazir says

    February 12, 2015 at 12:33 AM

    Good and understandable tutorial

    Reply
  24. Malik Ahmad says

    February 15, 2015 at 5:59 AM

    Thanks for tutorial 🙂
    so nice

    Reply
  25. Sandeep says

    February 23, 2015 at 2:58 AM

    Hi Md Ali Ahsan Rana,

    I’m getting an error “fetching ajax content” when i run my application in my local server xammp and also getting error each time when i refresh the pages of my project.

    waiting for your response

    thanks!

    Reply
    • Md Ali Ahsan Rana says

      February 23, 2015 at 7:31 PM

      There isn’t any ajax related code been shared on this tutorial. So, I am assuming, you are trying in a little different way. Thus I will suggest you to share your code/more info in some kind of code sharing site and put the link here. This will help to understand your issue more better.

      Reply
  26. Tharindu Dissanayake says

    March 12, 2015 at 3:55 AM

    nice tutorials.. thanks Mr.Rana

    Reply
  27. skemas says

    April 6, 2015 at 11:24 PM

    have entered $list = (object)NULL; but returns an errror:

    Fatal error: Cannot use object of type stdClass as array in C:\xampp\blog\codeigniter\application\models\blogModel.php on line 13

    Where should i place the line of code? Thanks! Greate tutorial for beginners

    Reply
    • Md Ali Ahsan Rana says

      April 7, 2015 at 2:37 PM

      I guess, that’s because of your PHP version. You can try with ‘Array()’/’array()’ instead of ‘(object)NULL’, if you are using older versions of PHP. Hope that helps.

      Reply
  28. Syed Sajid Ali says

    June 14, 2015 at 1:21 PM

    Please tell me how we load multiple pages in ci

    Reply
  29. Saranya Mani says

    June 24, 2015 at 6:09 AM

    Hi,
    I am Saranya.
    I worked lot on CMS, i want to learn Framework that too particularly code igniter, Please guide me how to learn from where to learn etc…

    Reply
  30. shilp says

    September 2, 2015 at 1:52 AM

    hi,
    i have a query. i just installed codeigniter using composer ( $ composer require “rogeriopradoj/codeigniter 2.2.1-rc.2” ) There i got folder structure on root
    -application
    -vendor
    and system file was in vendor folder. I m quite confused whats the se of this vendor folder. And how to start project . Please help me out

    Reply
  31. ArunValaven says

    December 18, 2015 at 6:12 AM

    Hai Rana.. There is in need to change the code from $list[0] = (object)NULL; to $list[1] = (object)NULL; in its second occurrence in “Create a model topic”. Array index value need to change from “0” to “1” to get escape from error in displaying output. Thanks for your simple and clear explanation about CodeIgniter.

    Correct code:
    $list[0] = (object)NULL;
    $list[0]->title = “first blog title”;
    $list[0]->author = “author 1”;

    $list[1] = (object)NULL;
    $list[1]->title = “second blog title”;
    $list[1]->author = “author 2”;

    Reply
  32. Amandeep Singh says

    February 11, 2016 at 6:38 AM

    Thanks sir for this blog

    Reply
  33. rady says

    February 14, 2016 at 10:45 PM

    Hi Mr.Rana
    I hope this blog so good for beginner CI like me.
    Thank you.

    Reply
  34. Haseem Mujahidh says

    April 4, 2016 at 8:48 AM

    thank you,Highly appreciate if you use file name and paths in your tutorial,then it would be a absolute beginners guide.

    Reply
  35. mariam says

    July 8, 2017 at 8:09 PM

    thank you for this… I will bookmark for the future

    Reply

Trackbacks

  1. Doctrine With Codeigniter Tutorial With PHP Code Examples says:
    October 7, 2024 at 11:45 AM

    […] have already discussed a few articles on CodeIgniter along with codeigniter basics. Codeigniter has good library/mechanism for manipulating database activity. Besides, it introduced […]

    Reply

Leave a ReplyCancel reply

Primary Sidebar

  • Facebook
  • X
  • Pinterest
  • Tumblr

Subscribe via Email

Top Picks

python local environment setup

Python Local Development Environment: Complete Setup Guide

In-Depth JWT Tutorial Guide For Beginners

JSON Web Tokens (JWT): A Complete In-Depth Beginners Tutorial

The Ultimate Git Commands CheatSheet

Git Commands Cheatsheet: The Ultimate Git Reference

web development architecture case studies

Web Development Architecture Case Studies: Lessons From Titans

static website deployment s3 cloudfront

Host Static Website With AWS S3 And CloudFront – Step By Step

Featured Dev Tools

  • JSON Formatter
  • Diff Checker

Recently Published

service worker framework integration

Service Workers in React: Framework Integration Guide

service worker caching strategies

Service Worker Caching Strategies: Performance & Offline Apps

service worker lifecycle

Service Worker Lifecycle: Complete Guide for FE Developers

what is service worker

What Is a Service Worker? A Beginner’s Guide

Dynamic Typing In Python

Dynamic Typing in Python: A Comprehensive Guide For Beginners

Footer

Subscribe via Email

Follow Us

  • Facebook
  • X
  • Pinterest
  • Tumblr

Explore By Topics

Python | AWS | PHP | C# | Javascript

Copyright © 2025

https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_22c10c88accdcf77c17022f11a6298efa0aec170babc6004b99d5514f125e85590226160741f7752c43d322339894cf2af4ec32bbd60c57d1336fa79c1d5b6b0.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_c402e38f1879c18090377fb6b73b15ac158be453ecda3a54456494fe8aba42b990c293bae5424e5643d52515ffc2067e0819995be8d07d5bba9107a96780775c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_ffc3511227531cc335353c54c3cbbaa11d0b80e5cb117478e144436c13cd05495b67af2e8950480ed54dbdabcdcef497c90fdb9814e88fe5978e1d56ce09f2cf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_d57da9abfef16337e5bc44c4fc6488de258896ce8a4d42e1b53467f701a60ad499eb48d8ae790779e6b4b29bd016713138cd7ba352bce5724e2d3fe05d638b27.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_edc0e9ef106cc9ef7edd8033c5c6fcff6dc09ee901fd07f4b90a16d9345b35a06534f639e018a64baaf9384eee1df305570c1ecad747f41b787b89f53839962b.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bc2182bb3de51847c8685df18692deda654dbf90fb01b503eb1bb0b68b879a051b91f30a9210ed0b2ba47c730db14b159cd9391ffdcd7117de397edd18366360.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_dccc492dbbfdac33d1411f9df909e849c7268fcf99b43007f278cde3a0adc0ae00e8cae5ec81cf255b9a6eae74e239ba1fa935572af77173219cb081f7d2327d.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_00bacf9e36181aac2b666d110cd9d82257f846766e7041b2d7b3c909b458982931ccc9b203e37098fbdfcf43ca359cf04e3824a724a6789fc204196d3a72ad29.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_65d41e8acf8460659d5800381e03c2a9dd52ec71287a6f20307e1eb7da27691a8e74e4408e23656afa7b5bd74b82697984fd2b1d4501251c6e73c6a935b6b92f.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_aa5a5d229b421633f4247380e1e8c0a4854f82efb35d13a5b07b7b8fbe22e98842a580f063e5965345a51c477a7f5c2585edf8dd7d896b2438dc61f91d8d970c.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_bb8058a9e234a7ffaa98891b1df7f6b8e67410e6984568b151daa05113b8c7f89d7b5918ae73f020998a16f7f5a087a13d6a9a5e5d7c301e2ca12fd9d1f8d177.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_647fb67570c6108fb10ae6785a1abdbecac99ffcf80351d0bef17c3cf783dce497b1895fcdaae997dacc72c359fbfb128cc1540dd7df56deb4961e1cd4b22636.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f7a298a0f1f754623fe3b30f6910ce2c1373f715450750bd7a391571812b00df1917e2be90df6c4efc54dbdfda8616278a574dea02ba2c7a31992768df8db334.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_df30604d5842ef29888c3c1881220dc6d3f8854666d94f0680c5f38aa643c5fb79b10eb9f10998d8856eb24ca265783195937434fd6c2bb8e4846df0277a7fb7.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f17fe6fb0993f1703181d7ae9e9ea570f3d33a43afd6f2a4567daa1a6745698c7b8193dc72d50991d2dd87cd3dcf663959206607d193a9b57926d061a1f50aef.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_945dcbab2c2a131f3c90f4fb91776b76066d589f84fb55bff25cd5d79a56218000616bfca1f0af9a74f32348693707af49e8fe624de8aa34f1e1c5b6a25709cf.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_65820d252e1b93596de6697fd5f02483f3e2524a0696c7d698b64745edb32bf5831a90e556842f5f88c8209766cc78ca3a41cf783d20236a9f90d4a7ea7b3e72.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_7286884797a1210857e2a36f8ab46604b0034b6abf512380447a5763c873db6a72b8547f660053de0ea69faef1eb64878f39ff4b0ea86c963efab95764a3bf5b.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_cbcf6c279ac6c6a25ae138bf964e64a5fd90d22dcdf8a53b6fe7b72cefa51063bfb0181a6e50dd2acdcae2795619887d1d83b10461e44e5103be756f2588d837.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_47965bc586b95810c925b9df3314e0c9a5cd121e70ca0831f87df0bc034695de4f83ecf2def86f737e14614ee138794473cf32cd3082a5d38db9dec0c1f266fa.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_12aa201cea075846d266536aa222d64d4088b851d87f55dac5e611b77add6826c8ebc6e82650fcd1a9e88a05a0072dedd195719c5f64cd4580a0acd8aee05d92.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_eaa93529c38925eb07368c361382956fbd910b5106b8589fa7e2e15a59c46437de3698d50ec4754bc45e6dfac47b3f41cc4c6112d7ede071ca8950385d4987dc.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_231ce2ef321bd111ab36d3c002fe5f745d1948c2bb3885f3f060983d08a7198414aa7e9fabdc0689a85d0370a73475a8ed94aa2bea5f473a9d70ab94d286778b.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_d87ea86dd0e7ecdd5fe7a5bb67becf943e57c3add866b456034d51663d099031bd563e12f61fdccc044969adf938a8584ed22ccd401ab8b669e20e4f92fb54e8.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_35311c3d71a3605fad4e1d6b50f3911311cdcc46418bdf56d6d0308a75a69585269ee7582a335e29989adf308fa1a81a10a2c2d4e257e9d680447a4996f6269e.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_f4fc182ef03c12e9dcadd6febc3dbaa4a29134469057ca9e8ec0be2f2de29a494514ff4b59798e74debf26f78b2df2b3e2665c69b77035761fb463b783202915.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_85c0f2769456e60153b0fd8364b82a035da53384f62de342d9bdca806f3f1ea56486919a00497a18d457949c82bf8bfacc4423fc332074ddf71a49a8fe628fff.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_67f99bef3678c549a14b5f2ff790cce6aba338dca29020755444231b45fa0f980f795e3658496ba70739a099b47b22bc2eab564343ac6132309de3adbbae3455.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_09eecfdd96206ed13830b4b93cfb2cc75cd38083671a34194437b5734b5bb38712209dc335b07e3266ceb3c3a44a155b9bbe5f3e0e1105b19dd45d3def76f020.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_4c089fbdb88e3b624a6f884d3ba1bf606f003bfcd3742376d0d353cd62181dc663aa3811a56361c3100de488fc4d6595a50de2b26f058921ba74f5f2c1b5be00.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_897ff6ac314c5f5e0f496c6af624bd9abf296a02cb5aeb850b9220b6dc3ce2fc4004cb02ed8b59d59d4b9c9d90f050d6eebc1d08ecaebab2f671f7d9367e6410.js
https://codesamplez.com/wp-content/cache/breeze-minification/js/breeze_67d1e619e71d36ae00ddcf85ee18628bb4eb64fcb3d6119b463e75cb987013420a21136d19cd03e6634ccc01cfa9af4a357930e4cf6900953b7812efb4f249fb.js