Questions tagged [codeigniter]

CodeIgniter is an Application Development Framework - a toolkit - for people who build websites using PHP. Created by EllisLab & fostered by BCIT it is now a project of the CodeIgniter Foundation. The framework implements a modified version of the Model-View-Controller design pattern. Use this tag for questions about CodeIgniter classes, methods, functions, syntax, and use. There are two major versions: 3.x and 4.x, addressing different system requirements

CodeIgniter is an web application framework created by EllisLab Inc, and it is now a project of British Columbia Institute of Technology. The framework implements a modified version of the Model-View-Controller design pattern. It is praised for its performance and the quality of its documentation. It's currently licensed under the MIT License, although the previous version was released under the Open Software License ("OSL") v. 3.0.

CodeIgniter is an open-source rapid development web application framework for building dynamic websites with PHP. "Its goal is to enable [developers] to develop projects much faster than writing code from scratch by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries." The first public version of CodeIgniter was released on February 28, 2006, and the latest stable version 4.2.10 was released on November 5, 2022

CodeIgniter is loosely based on the popular Model-View-Controller development pattern. While view and controller classes are a necessary part of development under CodeIgniter, models are optional.

With more than 18.2k stars on Codeigniter's repository, it's also among the most starred PHP Framework on Github.com

These are generally regarded as pros of the framework:

  • Nearly zero configuration & No restrictive coding rules
  • Small footprint
  • Performance
  • Easy to learn
  • Great documentation
  • No restrictive coding rules

These are generally regarded as cons of the framework:

  • No built-in ORM
  • No built-in templating
  • Doesn't utilize namespaces
  • Doesn't utilize PHP's auto-loading feature
  • Application code is tightly-coupled with the framework

CodeIgniter Versions

Current Stable Version: 4.2.10 (Release Date: November 5, 2022)


Top Tips For Codeigniter

One of the most commonly asked questions in Codeigniter on Stack Overflow is when I view my page and get the error 404 "Page Not Found". It would help if you looked at a couple of solutions before asking the question.

  1. Solution 1: Check the first letter of the class name and filename of the controller and models in the Uppercase example: Welcome.php

  2. Solution 2: If base_url() returns unexpected results, it's because you have not set a $config['base_url'] value.

  3. Solution 3: If you have not configured your CodeIgniter application/config/config.php file to remove $config['index_page'] = ''; then you will need to include the index.php in your URL

  4. Solution 4: After all settings, you need to load the form URL etc.. in autoload.php $autoload['helper'] = array('url', 'file', 'form', 'security');

    http://www.example.com/index.php/site
    

Note you will need a .htaccess file when you are removing index.php .htaccess for Codeigniter 2 & 3


Frequently asked questions


Online resources

69561 questions
6
votes
7 answers

Does there exist a way by which i can use WMI classes in java

Hi i want to use WMI classes to find out the application and products information. But the problem is that i want to use java or any scripting language like python, javascript or perl. I have heard about JWMI, it may be an option. Can anyone help me…
amod
  • 4,190
  • 10
  • 49
  • 75
6
votes
3 answers

Some basic questions after looking at the CI sourcecode

I was just looking at the CodeIgniter source code and I came across a couple of things that I can't seem to figure out; I'm not sure what they mean, and since they're mostly like one or two symbols it makes it hard to search on both google and…
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124
6
votes
1 answer

Build tables for ion auth and codeigniter

I have Codeigniter and Ion Auth installed on MAMP. I have the libraries working but I'm not sure how to build the required database tables for Ion Auth. Is there a preferred / best-practices way of doing this? Should I copy a query code from…
starsinmypockets
  • 2,264
  • 4
  • 34
  • 45
6
votes
4 answers

illegal 0000-00-00 00:00:00 timestamp being sent by php to mysql using codeigniter

here is a Database_update_entry function in my CodeIgniter model which gets executed upon successful form submission. $this->input->post('item_sl'), …
Rakib
  • 12,376
  • 16
  • 77
  • 113
6
votes
3 answers

Error 502 Bad Gateway When Using CodeIgniter

The following code is run from my controller and causes a 502 error bad gateway on one server. I have been unable to reproduce on my server. What are some causes of 502 Bad Gateway? function index() { $this->_reload(); } function…
Chris Muench
  • 17,444
  • 70
  • 209
  • 362
6
votes
2 answers

Codeigniter 4 - how to show 404 page?

It's a very silly question but I can't handle it :) In Codeigniter 3, I just used show_404() function in any controller to show 404 page. How could I do the same with Codeigniter 4?
Anton
  • 73
  • 1
  • 1
  • 6
6
votes
4 answers

Creating a 'People who viewed this also viewed' list

I'm thinking of creating a 'People who viewed this also viewed' list that you see on amazon, yelp and other online sites. Right now I'm thinking of creating a new table with 'product_id', 'last_viewed_product_id', 'hits' where when a user goes from…
Nyxynyxx
  • 1,165
  • 7
  • 21
  • 30
6
votes
7 answers

How to debug Codeigniter 4

whatever error occurs in Codeigniter 4 Its always showing default message How to get exact error message in Codeigniter 4
Boominathan Elango
  • 1,156
  • 2
  • 7
  • 20
6
votes
4 answers

How can I send a daily email notification to users in PHP?

I have a simple user signup form with a checkbox that lets users get a daily email notification if there was activity on any of their projects...much like Stack Overflow has a "Notify xxx@example.com daily of any new answers". My current thinking to…
zee
  • 661
  • 2
  • 10
  • 17
6
votes
8 answers

What's the equivalent of $this->db->last_query() in Codeigniter 4?

I just started learning Codeigniter 4. My query always generates NULL and I don't know why. How can I see the generated SQL Select command just like Codeigniter 3? In Codeigniter 3 this command does the job: echo $this->db->last_query(); And this…
rostamiani
  • 2,859
  • 7
  • 38
  • 74
6
votes
3 answers

Share CI models between different applications

I'm still trying to figure out a way to get a mobile site running. I have a web app in CodeIgniter and I would like to create a mobile version of it. However, I don't want to rewrite too much of my code, especially not my models.. (Since they return…
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124
6
votes
2 answers

How to rewrite from http requests to https on specific pages of my site?

Hey people. I see that this topic is repeated over and over on SO but I tried several solutions posted here and none of them worked quite for me. So basically - I know how to change specific pages on my website so that they're in https mode.…
Pavel
  • 5,213
  • 10
  • 34
  • 47
6
votes
1 answer

codeigniter url case sensitive issue

I have written a controller with name CMS (capital letter). When I call the link http://localhost/CI/testing/admin/cms/insert, It has no problem. Its working fine in localhost. After uploading that page to server and when I execute the statement,…
Nisha haridas
  • 332
  • 1
  • 8
  • 22
6
votes
1 answer

IFNULL(COUNT('id'),0) in Codeigniter

I believe there is an error in this line in Codeigniter using Active Records, but I cant seem to figure out the syntax on the second line with IFNULL() and COUNT() $this->db->select('places.*, category.*') …
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
6
votes
1 answer

Removing content from database, security precautions

UPDATE: I added the CSRF protection like Berdir told me, with the help of the link below to make my application work again. However.. I'm not quite sure what I did right now :D How is this going to make my app more secure? I'm particularly bothered…
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124