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

Wildcard subdomains for a single codeigniter application

Basically I'm trying to make a codeigniter app with localization subdomains such that if I access: ca.site.com -> it would run the same system but shows canadian content. us.site.com -> still runs the same system but shows american content. plus if…
VeeBee
  • 847
  • 4
  • 13
  • 30
6
votes
1 answer

Getting started with Phil Sturgeon's CodeIgniter Template library

I'm trying to use Phil Sturgeon's CodeIgniter Template library, but I can't get it to change my pages. I read the documentation, followed the steps there, Download Copy to application folder Create a views/layouts/default view (Auto)load the…
Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75
6
votes
2 answers

Codeigniter 2 forms on one page, validation_errors problem

On one of my websites I have 2 forms on one page, I am having a problem, with validation_errors(); basically what is happening, is for one of the forms I am checking for errors and if there are any errors I am doing some styling to turn the labels…
Udders
  • 259
  • 5
  • 16
6
votes
5 answers

how to retrieve HTTP $_GET values with CodeIgniter

i'm stuck with using $_GET variables with CodeIgniter, anyone can help me please?
6
votes
1 answer

Codeigniter not loading CI super object

I am trying to write a hook for my Codeigniter application. I'm trying to catch a session in my hook. Here is my code to load the hook: $hook['pre_controller'] = array( 'function' => 'getNav', 'filename' => 'LoadNav.php', 'filepath' =>…
criticerz
  • 3,397
  • 3
  • 23
  • 24
6
votes
1 answer

Changing name of the uploaded file in CodeIgniter (dots & underscores)

I got some problems with changing name of uploaded file: $config = array( 'allowed_types' => 'mp3', 'file_name' => $fulltitle, // Lets say we've entered 'a.s.d.f.mp3' 'upload_path' => './music/' …
CyberLom
  • 61
  • 1
  • 3
6
votes
1 answer

Class Example cannot extend from trait Restserver\Libraries\REST_Controller

I am trying to implement the following library in a new project. "chriskacerguis/codeigniter-restserver": "^3.0" I got a fresh codeigniter installation on my local server and I have done everything accordingly. Now I am trying to run the code its…
Paul Carrion
  • 99
  • 1
  • 5
6
votes
8 answers

Adding exactly 100 values to database using ajax

What is the easiest/fastest way to add 100 points to a database? Please assume all writes will not work due to duplicates, bad data, etc. I'm trying to update a database with exactly 100 values. Once I have a good piece of data, I need to add it to…
Phil Salesses
  • 862
  • 1
  • 9
  • 31
6
votes
4 answers

Codeigniter constructors. What is the difference?

I see two types of contructors in CI. For instance... class Blog extends CI_Controller { function __construct() { parent::__construct(); } } and class Blog extends CI_Controller { function Blog() { …
CyberJunkie
  • 21,596
  • 59
  • 148
  • 215
6
votes
2 answers

CodeIgniter - How to check if there is anything in the validation_error array

I'm wanting to display a general error message if there are any errors in the validation_errors() array, but if I do something like if(isset(validation_errors())) { echo 'error'; } then it returns back and says: Fatal error: Can't use function…
Cecil
  • 1,609
  • 5
  • 21
  • 26
6
votes
2 answers

Codeigniter - Active record - sql - complex join

I have a function that retrieves all tags from a table: function global_popular_tags() { $this->db->select('tags.*, COUNT(tags.id) AS count'); $this->db->from('tags'); $this->db->join('tags_to_work', 'tags.id = tags_to_work.tag_id'); …
Jack
  • 307
  • 4
  • 15
6
votes
8 answers

Is it possible that ci url will not work with index.php

Is it possible that ci url will not work with index.php.I dont want to add index.php in url. If someone adds index.php in url it should not work.I have tried many methods . Please give me suggestion. I have tried but it's not working RewriteEngine…
user3198563
  • 445
  • 3
  • 13
6
votes
2 answers

Problems with codeigniter on ubuntu

I’ve got Codeigniter on Ubuntu 10 (LAMP). I have an htaccess file: RewriteEngine On RewriteBase /dort #Removes access to the system folder by users. #Additionally this will allow you to create a System.php #controller,…
Tomer
  • 61
  • 1
  • 3
6
votes
3 answers

What is a good blog system for use with CodeIgniter?

I am designing a full featured website that includes a blog on the homepage. I want it to be full featured, but I dont want to spend forever coding it. Is there any good blogging system that can be easily integrated with CodeIgniter?
Nick Anderegg
  • 1,006
  • 1
  • 12
  • 25
6
votes
3 answers

What is the equivalent of "php artisan serve" for a CodeIgniter project?

I need to run CodeIgniter project from any location without the need to replace it on the directory (www) of my WAMP server. So I want to use the CLI and Composer for this. For Composer autoloading I follow these instructions from this link. Here is…
Hana90
  • 943
  • 5
  • 17
  • 37
1 2 3
99
100