-
Notifications
You must be signed in to change notification settings - Fork 3
kh411d/no-framework-php
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
/* 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]);
About
Who needs a framework?
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published