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

Add extra header information in codeigniter email

I would like to send some extra information on the emails which is sent from codeigniter library. Is there any way to configure or add this? I want to categorize all the outgoing mail from my site. I need to include sendgrid category header for…
Arun SS
  • 1,791
  • 8
  • 29
  • 48
6
votes
3 answers

How to enable user custom domains in PHP

I'm having a system where users can input their purchased domain into their profile, so when accessing their domain, it should replace their custom domain, e.g. http://domain.com/custom-name to http://purchaseddomain.com. So when they access their…
MacMac
  • 34,294
  • 55
  • 151
  • 222
6
votes
1 answer

Paypal IPN Issue with parallel payment

I'm using this http://www.binpress.com/app/paypal-adaptive-payments-pro-codeigniter-library/140 library and i'm using this as my ipn listener for a codeigniter project - http://pastebin.com/pMb7Zhz3. Basically i'm doing a parallel transaction using…
Catfish
  • 18,876
  • 54
  • 209
  • 353
6
votes
3 answers

Pagination do not correct display page numbers Codeigniter

My controller function function test($start_from = 0) { $this->load->library('pagination'); $data = array(); $per_page = 3; $total = $this->activity_model->count_by(); $config['base_url'] = base_url() . 'test'; …
Viktors
  • 935
  • 3
  • 13
  • 33
6
votes
6 answers

select max codeigniter

Im trying to get an max value with codeigniter from an table but it isnt working. This is the error i get: Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string Filename: database/DB_active_rec.php Line…
Augus
  • 495
  • 1
  • 8
  • 24
6
votes
2 answers

File permission with upload class of CodeIgniter

Hi I need to put a permission 777 to my uploaded files but I dont find any docs for uploaded files in codeigniter... Is it possible to put permission 777 with the upload class of codeigniter ?? $group_id = $this->input->post('group_id', TRUE); …
user1029834
  • 755
  • 3
  • 9
  • 18
6
votes
2 answers

Codeigniter PDO integration

i did lot of research on the web but i didnt find anything that could help me to use PDO in codeigniter. I saw in the change lof of CI 2.1.0(i think) that pdo driver was added to the framwork. I ended up now with a database.php config file that…
th3n3rd
  • 375
  • 1
  • 3
  • 20
6
votes
5 answers

In Codeigniter, how to pass a third parameter to a callback (form validation)?

I am currently using the Form Validation class (on Codeigniter) and setting rules. It works like this with two parameters (codeigniter.com/user_guide/libraries/form_validation.html): $this->form_validation->set_rules('username', 'Username',…
Dacobah
  • 779
  • 3
  • 15
  • 35
6
votes
5 answers

Facebook getUser() returns 0

I am implementing Facebook login using the PHP SDK with Codeigniter. I get the Facebook login popup, hit login, but I am unable to retrieve the user's id - it always returns 0. I have put the facebook.php and base_facebook.php files in my libraries…
Tom
  • 721
  • 3
  • 11
  • 28
6
votes
5 answers

Logout codeigniter

I have a logout controller in codeigniter : session->sess_destroy(); redirect('index.php'); } } This logs me out but when i call another controller…
The real thing
  • 103
  • 1
  • 2
  • 5
6
votes
2 answers

How to send variable data when redirecting to previous page

I am using the following codes to redirect my user to previous page after a particular task is done. if (isset($_SERVER['HTTP_REFERER'])) { $this->session->set_userdata('previous_page', $_SERVER['HTTP_REFERER']); …
black_belt
  • 6,601
  • 36
  • 121
  • 185
6
votes
2 answers

which folders to ignore in a codeigniter app when using version control

Which folders should I ignore when using version control on a project developed on the CodeIgniter framework? I am already ignoring the application/cache folder, but are there any else?
longneck
  • 11,938
  • 2
  • 36
  • 44
6
votes
1 answer

Codeigniter session security

How can I increase the security of my sessions? $this->session->userdata('userid') I've been throwing this little bad boy around for my ajax calls. Some cases I haven't. Then I was like, is this really secure using id from the DOM? what if the DOM…
el_pup_le
  • 11,711
  • 26
  • 85
  • 142
6
votes
4 answers

Create Simple Codeigniter library

For my current project i decided to create a library for some common functionalities. Ex : Login_check,get_current_user etc. With my little knowledge i created a simple one but unfortunately its not working. Here my library : FileName : Pro.php and…
Red
  • 6,230
  • 12
  • 65
  • 112
6
votes
4 answers

How can I instantiate multiple instances of the same object in Codeigniter?

With traditional OOP, i would (or could, rather) create a model / object that represents a User, with properties that reflect that, i.e. name, id, job title etc. I could then create a new instance of that object and assign it to a variable, and if i…
Dan Matthews
  • 1,245
  • 2
  • 12
  • 24