Custom MVC with PHP
Basic PHP MVC framework.
Run composer before starting for installing or updating modules.
Check the source code refering to examples of controller, views, models
Features :
Model : Impleted using Eloquent for database models : http://laravel.com/docs/4.2/eloquent
- Composer module : https://packagist.org/packages/illuminate/database
View :
Layouts - create custom layouts - has default.php set as default layout
- Calling custom layout app/views/Layout/mylayout.php
$this->layout('mylayout');
Elements - create elements to be called in view app/views/Element/default.php
Inside view file
echo $this->element('default');
Sending data from controller to view -
$this->view('index', ['name' => 'myName', 'message' => 'We have users controller too.']);
- Above example sends array of string to index view. Same can be accessed by
echo $this->data['name']; echo $this->data['message'];
Controller :
-
Default controller is home.php - HomeController
-
Default action is set to index method of HomeController
-
Can use multiple model in one controller
$this->uses(array('User', 'Location'));
$this->model->User->myFunction();
Feel free to fork or using it in your basic projects. :)
Thank You.