Skip to content
No description or website provided.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
controller
library
model
view
.htaccess
.travis.yml
README
config.php
index.php
routes.php

README

/* Whats this?? */
its a No Framework PHP MVC.
a really really small framework... believe it or not!
Only 20 kb unzipped

/* How to Create Routes? */
 Define your route on routes.php file, and add route by calling,                            
 // load::l('router')->add('/[uri path]','[template file name]');  
 
 load::l('router')->add('/','home');
 load::l('router')->add('/home/(.+)/([0-9]+)','home'); //Regex Route

/* How to Create Controller? */
 Save your controller file at controller dir, ex: /controller/home_c.php 
 the class name will be Class Home_c{}, and then extend it with Controller abstract class 
 
 Class Home_c extends Controller
 {
  public function __construct()
  {
   //Getting Regex Arguments from URL Segments if exists (optional)
   $reg = load::l('router')->reg_segments;
   
   //Set Template Variable
   $this->setOutput(array('hello'=>"Hello World!"));
  }
 }
 //!important!
 Controller must be load directly on your view file 

/* How to Create your Template/View? */
 Save your view file at view dir, ex: /view/home.php 
 
 //Optional (you may want a simple static template)
 On your view file, load the CONTROLLER AT THE VERY TOP OF CODE LINE, by calling 
 extract(load::c('[controller name]')->getOutput());
 and extract it if you have output variables from the controller.
 
 You may load other view/template by calling 
 // load::v('[template file name]');
 
 home.php <<<
 1. <?php extract(load::c('home_c')->getOutput()); //Load and extract controller variables ?>
 2.
 3. <?php load::v('header'); //Begin HTML ?>
 4. <h1><?php echo $hello;?> </h1>
 5. <?php load::v('footer');//End HTML ?>
 
/* How to Create Library/Model? */
 Basically you only need to create a reguler class base on your model/library file,
 its the same like controller does.
 ex : /model/home_m.php , and the class name will be, Class Home_m {}
 ex : /library/mylib_l.php , and the class name will be, Class mylib_l {}

 You may load the library or model anytime anywhere by calling 
 // load::m('[model name]')->[method name]
 // load::l('[library name]')->[method name]
  
/* Wrappers */
 load::c('[controller name]',[arguments array optional]);
 load::m('[model name]',[arguments array optional]);
 load::v('[view name]',[arguments array optional]);
 load::l('[library name]',[arguments array optional]); 
  
Something went wrong with that request. Please try again.