A Simple Model-View-Controller(MVC) PHP Framework
, (*2)
Mikasa Framework is A Simple MVC(Model View Controller) PHP Framework. Mikasa Framework is suitable with you who familiar with CodeIgniter or just new in this pattern., (*3)
You need to install xampp with >= php 5.6 and composer. The installation we have to option, you can just download or clone this repo., (*4)
$ git clone https://github.com/philiplambok/mikasa.git $ cd mikasa
or you can install with composer [Recomended], (*5)
$ composer create-project philiplambok/mikasa myapp --prefer-dist -vvv $ cd myapp
or just download from stable releases, (*6)
In MVC Pattern, you will familliar with Model (Class that interact with database), View (File that handle the UI) and Controller (Class that manage the logic and routing)., (*7)
You can run the project using build in php server, with type this command :, (*8)
$ php -S localhost:8000
That command will be running your code in localhost port 8000. You can open your browser and type to url box : http://localhost:8000, (*9)
Here is an example of a basic controller., (*10)
<?php namespace App\Controllers; use App\Core\Controller; class HomeController extends Controller { public function index() { return $this->view('welcome'); } }
All controller must be extends with class controller, and for using class controller you must use from namespace : use App\Core\Controller
. Like i said first, in mikasa framework, controller will be manage the route like CodeIgniter, so on that code will be running in 'http://localhost:8000'. yeah index() method is the default method., (*11)
If your program need some logic or interact to database, you can just create the model., (*12)
<?php namespace App\Models; use App\Core\Database; class User extends Database { public $username; // get all user in users table. public function getList() { $sql = 'SELECT * FROM users ORDER BY id'; $query = $this->db->query($sql); $result = $query->fetchAll(PDO::FETCH_OBJ); return $result; } }
All model will be extends with Database class. To connection with database, you can using query method in db attr: $this->db->query("query")
., (*13)
All views located in dir : App/Views
. You can create some html file and show them with controller. If you need some data in database you just create the model., (*14)