Questions tagged [codeigniter]

CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites 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 use in 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 3.1.10 was released January 16, 2019.

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 18k star 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: 3.1.10 (Release Date: January 16, 2019)


Top Tips For Codeigniter

One of the most common asked questions in Codeigniter on Stack Overflow is when I view my page I get error 404 "Page Not Found". There are a couple of solutions you should look at before asking the question.

  1. Solution 1: Check the first letter of class name and filename of controller and models is 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

68242 questions
663
votes
31 answers

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

I have a bunch of client point of sale (POS) systems that periodically send new sales data to one centralized database, which stores the data into one big database for report generation. The client POS is based on PHPPOS, and I have implemented a…
ArcticZero
  • 6,671
  • 3
  • 17
  • 8
398
votes
11 answers

How should I choose an authentication library for CodeIgniter?

I see there are a few. Which ones are maintained and easy to use? What are their pros and cons?
GavinR
  • 5,816
  • 7
  • 28
  • 43
243
votes
7 answers

Which version of CodeIgniter am I currently using?

Quick question. Is there something similar to a phpinfo() - that would display the version for CodeIgniter? Thanks.
Dirk
  • 6,445
  • 13
  • 47
  • 72
183
votes
7 answers

CodeIgniter: Create new helper?

I need to loop lot of arrays in different ways and display it in a page. The arrays are generated by a module class. I know that its better not to include functions on 'views' and I want to know where to insert the functions file. I know I can…
Jonathan
  • 8,146
  • 20
  • 64
  • 100
177
votes
3 answers

Only variable references should be returned by reference - Codeigniter

After the server PHP upgrade I am getting the following error with PHP Version 5.6.2 on Apache 2.0 A PHP Error was encountered Severity: Notice Message: Only variable references should be returned by reference Filename: core/Common.php Line Number:…
Techie
  • 42,101
  • 38
  • 144
  • 232
165
votes
9 answers

how to get last insert id after insert query in codeigniter active record

I have an insert query (active record style) used to insert the form fields into a MySQL table. I want to get the last auto-incremented id for the insert operation as the return value of my query but I have some problems with it. Inside the…
Afghan Dev
  • 6,691
  • 9
  • 42
  • 71
163
votes
32 answers

CodeIgniter removing index.php from url

My current urls look like this [mysite]index.php/[rest of the slug]. I want to strip index.php from these urls. mod_rewrite is enabled on my apache2 server. In config, $config['index_page'] = ''; My codeignitor root .htaccess file contains,…
Nihar Sarangi
  • 4,295
  • 7
  • 25
  • 29
153
votes
11 answers

CodeIgniter activerecord, retrieve last insert id?

Are there any options to get the last insert id of a new record in CodeIgniter? $last_id = $this->db->insert('tablename', array('firstcolumn' => 'value', 'secondcolumn' => 'value') ); Considering the table consits of fields id…
Dennis Decoene
  • 6,718
  • 5
  • 26
  • 41
143
votes
14 answers

Where do I put image files, css, js, etc. in Codeigniter?

Where is it acceptable to put css folders and image file folders? I was thinking inside the view folder? However the controller always reroutes the path to the base url so I have to specify the path in the .html file to where it sits, which is…
triq
  • 1,905
  • 5
  • 23
  • 24
133
votes
13 answers

How to insert multiple rows from array using CodeIgniter framework?

I'm passing a large dataset into a MySQL table via PHP using insert commands and I'm wondering if it's possible to insert approximately 1000 rows at a time via a query other than appending each value on the end of a mile-long string and then…
toofarsideways
  • 3,766
  • 2
  • 27
  • 48
124
votes
11 answers

CodeIgniter: How to get Controller, Action, URL information

I have these URLs: http://backend.domain.com/system/setting/edit/12 http://backend.domain.com/product/edit/1 How to get controller name, action name from these URLs. I'm CodeIgniter newbie. Are there any helper function to get this…
noname.cs
  • 1,841
  • 4
  • 16
  • 20
116
votes
27 answers

How to remove "index.php" in codeigniter's path

How do I remove the "index.php" sticking out in every path in codeigniter somewhere in the center? I want clean non index.php-fied URLs?
OrangeRind
  • 4,618
  • 12
  • 42
  • 56
115
votes
14 answers

How to print SQL statement in codeigniter model

I have a sql statement in my model, I then say $query = $this->db->query($sql, array(fields, fields1); if ($query) { return true: } else { echo "failed"; return false; } My query always fails, how do I get php to print the exact sql…
Technupe
  • 4,143
  • 11
  • 30
  • 35
109
votes
9 answers

PHP_SELF vs PATH_INFO vs SCRIPT_NAME vs REQUEST_URI

I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the main controller: index.php. However, I don't like to see index.php in the URI. For example, http://www.example.com/faq/whatever will route to…
Eli
  • 88,788
  • 20
  • 72
  • 81
106
votes
11 answers

CodeIgniter - accessing $config variable in view

Pretty often I need to access $config variables in views. I know I can pass them from controller to load->view(). But it seems excessive to do it explicitly. Is there some way or trick to access $config variable from CI views without disturbing…
AlexA
  • 3,838
  • 8
  • 47
  • 83
1
2 3
99 100