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
3 answers

Codeigniter: Paypal IPN and csrf_protection

I'm working with codeigniter-paypal-ipn and have csrf_protection enabled. This seems to block the access from Paypal to my IPN controller. If i disable csrf_protection it works just fine, with csrf_protection enabled, paypal IPN service throws a 500…
AFRC
  • 902
  • 3
  • 9
  • 27
6
votes
3 answers

What Defines the Traditional "Page" Concept in MVC?

I currently use CodeIgniter as my framework of choice when using PHP. One of the things I am wrestling with is the idea of a "page", and how to represent that properly within MVC. To my knowledge, CodeIgniter has a front controller that delegates…
Joe
  • 425
  • 1
  • 5
  • 13
6
votes
5 answers

Codeigniter Change loaded language

Currently i have a language loaded inside MY_Controller which extends CI_Controller. But inside a special page which controller (let's call it ABC controller) extends MY_Controller, I need to override the loaded language with another language. I…
coder
  • 73
  • 1
  • 2
  • 5
6
votes
2 answers

Possible hacking attempt. How to tell if my db has been compromised

I have the following in my log file with seconds apart. I'm assuming something was trying to find my database or an admin page or something, but i'm not sure. Should I be worried about this and how can I tell if my db has been compromised? ERROR -…
Catfish
  • 18,876
  • 54
  • 209
  • 353
6
votes
6 answers

Storing a Yes / No radio button into a MySQL database

I've seen a Yes/No form radio buttons value be stored/saved in a couple different ways. I wonder which way is better and why? This is for a PHP/MySQL application with a typical Yes/No question as part of a form. 1.) Store it as 1, 0 or null. 1 being…
jjwdesign
  • 3,272
  • 8
  • 41
  • 66
6
votes
1 answer

Fat Model Skinny Controller in CodeIgniter

I've been using CodeIgniter for a while, and have a decent knowledge of MVC, PHP etc. However, I'm finding it hard to adhere to the Fat Model Skinny Controller ethos. I've seen a lot about it; including what pseudo code to include in each file, but…
Toddish
  • 516
  • 2
  • 12
6
votes
1 answer

jquery ajax returns error but is success

I have the following JS function change_ajaxarea1(){ navigator.notification.activityStart(); $('#ajaxarea1').load('http://server.net/droiddev/backbone1/index.php/welcome/',…
CI_Guy
  • 1,039
  • 2
  • 22
  • 39
6
votes
4 answers

CodeIgniter Controllers Loading Twice When Using Parameters in the URL

I'm having an issue where my CodeIgniter controllers are being called twice. It only seems to occur when I am using parameters in the uri (/newsletter/confirm/a1938cas893vf9384f0384f0943). If I remove the parameter from my function it only loads the…
aberrant
  • 61
  • 1
  • 3
6
votes
3 answers

Mysql Codeigniter Active Record - How do I do a where_in query and return the correct order of results?

I have a set of IDs passed in a particular order which needs to be retained. I am querying from several left joins the data related to each ID. The IDs are returned from a search so the order must be kept to make the results valid (otherwise it…
Anthony
  • 270
  • 1
  • 4
  • 9
6
votes
5 answers

Cron jobs in codeigniter

I am trying to do a cron job with a site built in CodeIgniter - I've got access to the CPanel cron feature can anyone suggest the best way to setup a cron job using CPanel? I am using CodIgniter so cannot be sure how to call a controller within a…
Zabs
  • 13,852
  • 45
  • 173
  • 297
6
votes
2 answers

PHP/CodeIgniter - Setting variables in __construct(), but they're not accessible from other functions

I'm happy a bit of a variable scoping problem. Maybe I just need more coffee... Here's my (simplified) code - this is in CodeIgniter 2: class Agent extends CI_Controller { public function __construct() { parent::__construct(); …
Jack
  • 9,615
  • 18
  • 72
  • 112
6
votes
1 answer

CodeIgniter active record, Add IF statement in ->select() function

I have this query: $this->db->select(" IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' )" , 'user_judgement'); I get syntax error on `'NotExists'` ) If I run the query directly…
fatnjazzy
  • 6,070
  • 12
  • 57
  • 83
6
votes
3 answers

How can I keep the same url in the address bar for every page?

I have a site built with Codeigniter where there are a lot of pages and directories. Let's say the site name is www.example.com (this is the index page). If the user goes to another page, for example clicking on the "about" link, how can I make the…
Maulik patel
  • 1,551
  • 8
  • 22
  • 44
6
votes
1 answer

Codeigniter, Facebook javascript SDK, PHP SDK Redirect after facebook login doesn't getUser() until refresh

The process is as follows. 1. User clicks Facebook Login button 2. User signs in and grants perms 3. Facebook redirects uses FB.Event.subscribe auth.login to redirect my login controller 4. My login controller loads the fbconnect module and chains…
6
votes
1 answer

How can I produce a synchronisable calendar for web and mobile devices (natively)?

I have built a web application in PHP using CodeIgniter. The application is based heavily around a calendar that allows the user to add, edit and remove events to that calendar. One of the major requirements for the system is to use the native…
Mike
  • 8,767
  • 8
  • 49
  • 103