Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What design pattern is Codeigniter using?

Fairly straightforward question:

I know that Codeigniter is a MVC framework - however what design pattern is Codeigniter using?

From first look it seems like Facade, but I could be wrong.

Edit:

Perhaps I should describe Codeigniter for those who don't use it.
In Codeigniter you have a concept of a Controller and a Model, which each has their own separate folder. In each of the folders you create a file: cart.php:

<?php

class Cart {
 //...
}
?>

Then you can also have a model:

<?php

class User {
    function login(){...}
}
?>

Inside of the class Cart, you can use the login function in User by simply using $this->user->login()

I find this interesting because the framework makes an object of the User object and the programmer does not.

like image 947
Natalie Adams Avatar asked May 31 '10 21:05

Natalie Adams


People also ask

What are PHP Design Patterns?

PHP Design patterns is an Object-Oriented Programming (OOP) concept that is now also used in Drupal 9 projects. With Drupal's adoption of modern PHP and OOP concepts since version 8, design patterns can be leveraged for cleaner and more robust programming.

How does CodeIgniter framework work?

CodeIgniter is a PHP MVC framework used for developing web applications rapidly. CodeIgniter provides out of the box libraries for connecting to the database and performing various operations like sending emails, uploading files, managing sessions, etc.

What is model in CodeIgniter?

Models are PHP classes that are designed to work with information in your database. For example, let's say you use CodeIgniter to manage a blog. You might have a model class that contains functions to insert, update, and retrieve your blog data.


1 Answers

In Codeigniter you have a concept of a Controller and a Model, which each has their own separate folder.

They have setup their main router class such that it searches for corresponding controller and model files, it can even go recursive. This has nothing to do with any design pattern, it is just a folder organization.

I find this interesting because the framework makes an object of the User object and the programmer does not.

Yup, they have created a lot of stuff ready-made and to be used any time you want. The User class is used to control whole user system.

Basically, as you said, the main design pattern used is MVC, rest of the things are controlled by different core classes for a specific task.

like image 184
Sarfraz Avatar answered Oct 06 '22 01:10

Sarfraz