PHP MVC

Ĺatĕst Ùpdãte
1 min readMay 24, 2020

--

how to php much faster and more secure to run?

PHP MVC

MVC :

Model view controller to be use in single page application(SPA).This method minify code and reusability. Beginner learn to much complex and hard work to easy to implement in MVC.

Features :

  1. Multiple time calling single function.
  2. separate the operation easy to manage.
  3. SPA is one time reload page.
  4. client may not don’t guess which backend used.
  5. Mode-Database,View-HTML,Controller-PHP.

index.php

$controller=’home’;

$function=’home’;

if(isset($_GET[‘controller’]) && $_GET[‘controller’]!=’’){

$controller=$_GET[‘controller’];

}

if(isset($_GET[‘function’]) && $_GET[‘function’]!=’’){

$function=$_GET[‘function’];

}

if(file_exists(‘controller/’.$controller.’.php’)){

include(‘controller/’.$controller.’.php’);

$class=$controller.’Controller’;

$obj=new $class();

if(method_exists($class,$function)){

$obj->$function();

}else{

echo “Function not found”;

}

}else{

echo “Controller not found”;

}

Download source code to gitlab

https://gitlab.com/Smahavishnu/PHPMVC

--

--