MVC rule



1. mySQL tables will always be lowercase and plural e.g. posts, books
2. Models will always be singular and first letter capital e.g. Post, Book
3. Controllers will always have “Controller” appended to them. e.g. PostController, BookController
4. Views will have plural name followed by action name as the file. e.g. posts/view.php, books/buy.php




For Example :


1. models process


models => post.php

<?php
class Post extends Model {

}

2. controllers 


controllers  = > postscontroller.php



<?php
class PostsController extends Controller {

    function view($id null,$name null,$phone null) {
    
        

       // view / display code here

    }
    
    function viewall() {

      // view all posts
     

    }
    
    function 
add() {
       

        

        
 // add post code here
        

            
    }
    
    function 
delete($id null) {
        

        delete post code here
   
    }

}

3. views = > posts =>


viewall.php
add.php
delete.php


Advertisements