Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Three tier architecture

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 12
    Comment on it

    Hi all,

    I am explaining here how we can build large interactive applications in any technology not even in php. We can build a very powerful applications using Three tier architecture known as Model View Controller i.e MVC. There are so many mvc frameworks used in php such as cakephp, codeigniter, zend, laravel, yii etc. As we all know that php is open source, we can also develop our own mvc application.

    Model: Model defines the database structure, It deals with the controller and send the response to the controller.

    View: View defines the user interface of the application based on MVC platform, when the view is loaded, it interacts with the controller and controller interacts with the model to show the result in the View page.

    Controller: Controller is the middle and main part which interacts with the both Model and View, It deals with the Model to get the results and deals with the View to display the result retrieved from the model.

    we will build a small Hello World application to show how mvc works:-

    1. Create a folder with the name model.
    2. Create a folder with the name view.
    3. Create a folder with the name controller.
    4. Create a folder with the name assets.
    5. Create a folder with the name config.

    Inside model folder , we will keep the model files, inside the controller will keep the controller files and in the view folder we will create a folder name and files. 1. Create a connection file, connect.php under config folder and write a piece of code:

    $conn = mysql_connect('localhost','root','');
    mysql_selectdb('dbhelloworld',$conn);
    
    1. Create a Hello.php file inside the model folder and write a piece of code:-
    include "config/connect.php";
    class Hello{
    public $name;
       public  function display_name(){
    $this->name = "Hello World";
    return $this->name;
    }
    }
    
    1. Now create a HelloController.php in controller folder and write a piece of code:-
    class HelloController{
    public function view($filename = ""){
    if (!class_exists('Hello')) require "model/Hello.php";
    if ($filename == 'index'){
    Hello::display_name();
    $this->call($filename);
    }
    else{
    $this->call($filename);
    }
    
    }
    private function call ($filename){
    if (file_exists("View/".$filename)){
    $filename = $filename.".php";
    header('Location: View/$filename');
    }
    else{
    return $this->show_error();
    }
    
    }
    private function show_error(){
    return "File not found!!";
    }
    }
    
    mvc php

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: