Skip to main content

MVC (Model View Controller) : Codeigniter Club



MVC will divide an application into three functional parts:

  • Models — deals with your database, carries out computations, and more. In short, it is where your business logic is located.
  • Views — forms the presentation layer of the application, where the data from your models are embedded.
  • Controllers — used to connect models and views. A controller will route user requests to the appropriate model. After that, once the model has done its job, the controller loads the relevant view.

This architectural pattern also gives developers the flexibility to reuse code for multiple views. For example, you can apply the same navigation bar on every webpage of your application.

Moreover, as both views and models are entirely separate, the front-end developers can work in parallel with the back-end team to speed up the development process.

Note that CodeIgniter also subscribes to Object-Oriented Programming (OOP). As such, models and controllers are PHP classes that extend the base classes provided by the framework.

Views are also called PHP files, but the bulk of their content is HTML/CSS. Only a few snippets of PHP code are present, which are used to display the data from models.

PHP MVC Frameworks simplify working with complex technologies by;

  • Hiding all the complex implementation details.
  • Providing standard methods that we can use to build our applications.
  • Increased developer productivity, this is because the base implementation of activities such as connecting to the database, sanitizing user input etc. are already partially implemented.
  • Adherence to professional coding standards.

Comments

Popular posts from this blog

Create rest api to send curl request from codeigniter controller to google cloud for text to speech convert using codeigniter 3.

  Create Google Cloud account https://cloud.google.com/ You can create account using existing mail id. Obtain api key for Text to Speech. Create Rest Api to convert text to speech.  We are using cUrl method to send a request. Create Api.php and extend REST_Controller  <?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH . '/libraries/REST_Controller.php'; class Api extends REST_Controller{ public function __construct(){ parent::__construct(); } public function index_get() { $text = "Hi, how are you doing? Very well thank you. How about you? Not so well. But thank you for asking. How is the weather there? Oh, its very warm out here."; $audioContent = $this->generateSpeech($text); $this->response(array( "status" => 1, "message" => "question 1", "data" => $audioContent ), REST_Controller::HTTP_OK); } private function generateSpeech(...

Codeigniter registration form with validation using Ajax: Codeigniter Club

Codeigniter registration form with validation using Ajax In this tutorial, we will understand how to create a simple registration form using CodeIgniter.  Before starting we have to create a  Unique constraint (email id is a unique constraint in the database table) because if we enter a  Duplicate email id the  database will through a duplicate entry error and we can print an error. Otherwise, we can use another method using programming. we can check email-id already exist or not.  Create database table using Mysql database CREATE TABLE `registration` ( `id` int(11) NOT NULL, `username` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `country` varchar(100) NOT NULL, `password` varchar(200) NOT NULL, `agree` varchar(10) NOT NULL, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `update_at` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; Insert Data  INSERT INTO `registratio...