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
51
votes
15 answers

How to set cron job URL for CodeIgniter?

I am using CodeIgniter for my website. I have to use cron job to run one of controller function. I am using route in website. And also I am not using index.php in URL. e.g. http://example.com/welcome/show, here welcome is my controller and show is…
Sachin
  • 1,273
  • 5
  • 16
  • 27
50
votes
17 answers

GET parameters in the URL with CodeIgniter

I know that codeIgniter turns off GET parameters by default. But by having everything done in POST, don't you get annoyed by the re-send data requests if ever you press back after a form submission? It annoys me, but I'm not sure if I want to…
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
49
votes
8 answers

How do I run CodeIgniter migrations?

I know how to create them via http://codeigniter.com/user_guide/libraries/migration.html But once I've created my migration files, how do I run them?
Shamoon
  • 41,293
  • 91
  • 306
  • 570
49
votes
2 answers

Codeigniter - handling errors when using active record

I am putting together a few models for my codeigniter site and can't seem to find any word in the documentation of how to handle errors that could occur when using the Active Record system. The documentation demonstrates how to perform CRUD along…
Sergio
  • 9,761
  • 16
  • 60
  • 88
49
votes
14 answers

Fatal error: Call to undefined function base_url() in C:\wamp\www\Test-CI\application\views\layout.php on line 5

Hello I am new to CodeIgniter and PHP, I am trying to setup it for the firs time, but it give the following error. Fatal error: Call to undefined function base_url() in C:\wamp\www\Test-CI\application\views\layout.php on line 5   {main}( ) IN…
user1541058
  • 499
  • 1
  • 4
  • 3
48
votes
4 answers

Showing all session data at once?

I have tried the following but it is giving me errors: print_r($this->session->userdata()); How can I show all session data in CodeIgniter?
Simpanoz
  • 2,729
  • 10
  • 43
  • 64
48
votes
3 answers

Codeigniter: does $this->db->last_query(); execute a query?

Does query execution happen at the get_where() clause of the following codeigniter active record statement? $this->db->select('*'); $q = $this->db->get_where('Contacts', array('id' => $contact_id)); $sql = $this->db->last_query(); Or does…
James Bond
  • 699
  • 1
  • 10
  • 17
48
votes
8 answers

Error : ORA-01704: string literal too long

While I try to set the value of over 4000 characters on a field that has data type CLOB, it gives me this error : ORA-01704: string literal too long. Any suggestion, which data type would be applicable for me if I have to set value of unlimited…
hsuk
  • 6,770
  • 13
  • 50
  • 80
48
votes
8 answers

PostgreSQL next value of the sequences?

I am using PostgreSQL for my Codeigniter website. I am using grocery crud for add, edit and delete operations. While doing an edit or add, I want to rename an uploaded file dynamically based on the id of the content. I am able to do this using…
i_nomad
  • 795
  • 2
  • 7
  • 9
47
votes
12 answers

Getting data posted in between two dates

How can I retrieve data from the database by querying records between two dates using CodeIgniter's activerecord?
Thomas John
  • 1,903
  • 4
  • 24
  • 29
47
votes
4 answers

Codeigniter 3.x Authentication Library?

With the new Codeigniter 3.0 version what authentication libraries do you use? Flexi auth was very good and robust with great documentation for CI 2.0 but it is old and as I can see it is discontinued. Of course it does not work out of the box…
sotoz
  • 3,100
  • 3
  • 34
  • 41
47
votes
1 answer

array_unique showing error Array to string conversion

For getting the unique values i am using unique values. Below is the code i am using array_unique($results_external); aasort($results_external,"created_on"); $returns_buy_external[]=array_reverse($results_external, true); If i use the code like…
user3652109
  • 477
  • 1
  • 4
  • 6
46
votes
10 answers

Codeigniter : calling a method of one controller from other

I have two controllers a and b. I would like to call a method of controller a from a method of controller b. Could anyone help explain how I can achieve this?
koool
  • 15,157
  • 11
  • 45
  • 60
45
votes
6 answers

CodeIgniter: Decision making for creating of library & helper in CodeIgniter

After developing in CodeIgniter for awhile, I find it difficult to make decisions when to create a custom library and when to create a custom helper. I do understand that both allow having business logic in it and are reusable across the framework…
user179432
  • 463
  • 1
  • 4
  • 7
45
votes
11 answers

CMS based on CodeIgniter

I’m looking for a CMS based on CodeIgniter. Can you suggest what CMS I could use? I want to learn how to build a CodeIgniter application based using a CMS as a reference.
Adi Sembiring
  • 5,798
  • 12
  • 58
  • 70