Kecik Framework, micro framework
Rekening Mandiri: 113-000-6944-858, Atas Nama: Dony Wahyu Isprananda, (*2)
Is a framework with a very simple file system, so this is not a complex framework, but you can build and develop this framework to be a complex framework. This Framework support simple MVC where you still have to customize some code for get complex MVC, for Model just generate SQL Query for INSERT
, UPDATE
and DELETE
only, so for code execution that SQL Query please make your self freely as you want or using whichever database libaries. This Framework also support Composer, so as to facilitate you for adding a library from composer., (*3)
Name : Framework Kecik Author : Dony Wahyu Isp Version : 1.1.0 Country : Indonesian City : Palembang
Quickstart, (*4)
The First Step | The Second Step | The Third Step | The Fourth Step, (*5)
More, (*6)
Know More In | Header | Route | Config | Assets | Request | MVC | Controller | Middleware | Model | View | Url | Template, (*7)
top, (*8)
Install composer in your opration system, if not installed you can download it from Composer website, after download and initialitation, next you need make composer.json files with contents as follows., (*9)
{ "require": { "kecik/kecik": "1.1.*@dev" } }
next, run this command on console/cmd, (*10)
composer install
wait a minute until all run without error., (*11)
top, (*12)
Create index.php files or anything, and enter the code below:, (*13)
<?php require_once "Kecik/Kecik.php"; // or for composer require_once "vendor/autoload.php";
require "Kecik\Kecik.php"
for include system file of framework to the project that you want make.
then try run, if only displaying blank page without error message is mean successfull., (*14)
for how to use composer will not be discussed here, you can learn from documentation from composer website, both online and offline., (*15)
top, (*16)
Create variable from Kecik Class as below, (*17)
$app = new Kecik\Kecik();
then try running back, if not get error is mean you have successfull in this step., (*18)
top, (*19)
The next step is make Route for index and run the framework, following code:, (*20)
$app->get('/', function() { return 'Hello Kecik'; }); $app->run();
Once the code is written try running, so you can see "Hello Kecik" that mean you have successfull make view for route index/main page for your project., (*21)
The overall appearance code:, (*22)
get('/', function() { return 'Hello Kecik'; }); $app->run(); ``` ---- **Know More In** ------------------------------------------------------------- Header ---------- [top](#kecik-framework) Header use for do setting a response header ```php $app->get('hello', function() { $this->header(200); return 'Hello Kecik'; }); ``` ---- Route --------- [top](#kecik-framework) Route in contained kecik framework current is get and post, where get and post is request source and that mean is that route just will proccess on match request.For how to use, there are several ways, and very simple is without use Controller, external variable and template, as follow: ```php $app->get('/', function() { return 'Hello Kecik'; }); ``` With parameter: ```php $app->get('hello/:name', function ($name) { return 'Hello '.$name; }); ``` Parameter in route use ``:`` at front section, while for optional parameter can use ``(:)`` > **example:** hello/(:name) With Controller: ```php $app->get('welcome/:name', new Controller\Welcome($app), function ($controller, $name) use ($app) { return $controller->index($name); }); ``` Ensure that already makes Controller you want to use on that route. With Template: ```php $app->get('hello/:name', function ($name) { return 'Hello '.$name; })->template('template_kecik'); $app->get('welcome/:name', new Controller\Welcome($app), function ($controller, $name) use ($app) { return $controller->index($name); })->template('template_kecik'); $app->get('welcome/:name', function($name) { $controller = new Controller\Welcome($this); return $controller->index($name); })->template('template_kecik'); ``` ####**Group** Kecik Framework also supports grouping route. ```php $app->group('book', function() { $this->post('insert', function() { $controller = new Controller\Book($this); return $controller->insert(); }); $this->get('get', function() { $controller = new Controller\Book($this); return $controller->get(); }); $this->post('update', function() { $controller = new Controller\Book($this); return $controller->update(); }); $this->post('delete', function() { $controller = new Controller\Book($this); return $controller->delete(); }); $this->post('find', function() { $controller = new Controller\Book($this); return $controller->find(); }); }); ``` HTML just support method ``POST`` and ``GET``, if we want using method like ``PUT``, ``DELETE``, ``OPTIONS``, and ``PATCH`` we can using do **`Override`** ```html