Download the PHP package kecik/kecik without Composer
On this page you can find all versions of the php package kecik/kecik. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package kecik
Kecik Framework
Rekening Mandiri: 113-000-6944-858, Atas Nama: Dony Wahyu Isprananda
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.
Quickstart
The Fourth Step
More
Template
The First Step
top
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.
next, run this command on console/cmd
wait a minute until all run without error.
The Second Step
top
Create index.php files or anything, and enter the code below:
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.
for how to use composer will not be discussed here, you can learn from documentation from composer website, both online and offline.
The Third Step
top
Create variable from Kecik Class as below
then try running back, if not get error is mean you have successfull in this step.
The Fourth Step
top
The next step is make Route for index and run the framework, following code:
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.
The overall appearance code:
Know More In
Header
top
Header use for do setting a response header
Route
top
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:
With parameter:
Parameter in route use :
at front section, while for optional parameter can use (:)
example: hello/(:name)
With Controller:
Ensure that already makes Controller you want to use on that route.
With Template:
Group
Kecik Framework also supports grouping route.
HTML just support method POST
and GET
, if we want using method like PUT
, DELETE
, OPTIONS
, and PATCH
we can using do Override
Note: Applies to the use of the post, put, delete, options, and patch to use the controller and templates there are several steps that need to be prepared
is()
To get current value of the route
isPost()
To perform a check whether the request method is POST
, if true then the value is TRUE
if one then the value is FALSE
.
isGet()
To perform a check whether the request method is GET
, if true then the value is TRUE
if one then the value is FALSE
.
isPut()
To perform a check whether the request method is PUT
, if true then the value isTRUE
if one then the value is FALSE
.
isDelete()
To perform a check whether the request method is DELETE
, if true then the value is TRUE
if one then the value is FALSE
.
isPatch()
To perform a check whether the request method is PATCH
, if true then the value is TRUE
if one then the value is FALSE
.
isOptions()
To perform a check whether the request method is OPTIONS
, if true then the value is TRUE
if one then the value is FALSE
.
isAjax()
To perform a check whether the request method is AJAX
, if true then the value is TRUE
if one then the value is FALSE
.
First:
Setting path or location for assets, application (MVC), and template, following way setting:
Second:
create a folder / directory by setting the path before.
Third:
For folder/directory assets and application sure in which there sub folder/direktori
Config
top
For a big project and not simple we need some setting/configuration, for setting/configuration this framework also equipped with config, either for setting or to read settings
set()
Use set function from config to a set/add value
paramater
$key
is parameter key for a settingparamater
$value
is parameter value for a setting
Example:
get()
Use get function to get a value from a setting
parameter
$key
is key parameter for a setting where to get value
Example:
Configuration When Making Kecik Instance
Assets
top
Assets is importan for facilitate us work for add/delete assets as css, js and images, also very useful for a template, and assets juga can be adjusted by controller in used. Assets css and js have same structure while for images is diferrent.
add()
This function use for add a assets file as css or js.
paramater
$file
contains the name of the file that want to load assets, write without using extension
Example:
delete()
This cunction use to delete a assets file that want to load as css or js.
paramater
$file
contains the name of the file that want to load assets, write without using extension
Example:
render()
This function use to render a asset list or one asset that want to load as css or js
paramater
$file
contains the name of the file that want to load assets, write without using extension
Example:
images()
This function use to get link from image assets file.
paramater
$file
containt image assets file name that want to use.
Example:
url()
This function use for get link of assets file for images.
Request
top
Request is other use from $_GET
, $_POST
and $_SERVER
get()
You can use get function to get value from $_GET
.
paramater
$var
containt name from get variable
Example:
post()
You can use post
function to get value from $_POST
.
paramater
$_var
containt name from post variable
Example:
put()
You can use put
function to get value from PUT
.
parameters
$var
contains name from put variable.
Example:
delete()
You can use delete
function to get value from DELETE
.
parameters
$var
contains name from delete variable.
Contoh:
options()
You can use options
function to get value from OPTIONS
.
paramater
$var
berisikan nama dari variabel post
Contoh:
patch()
You can use patch
function to get value from PATCH
.
paramater
$var
berisikan nama dari variabel post
Contoh:
file()
You can use file
function to get value from $_FILE
parameters
$file
contains the name of the variableFILES
Contoh:
server()
You can use server function to get value from $_SERVER
paramater
$var
containt name from server variable
Exmple:
MVC
This Framework also support simple MVC, where route will call Controller and Controller will call Model or/and View.
Controller
top
For make controller is simple, we just make file with name as controller name and save into directory that setting before via config, The following simple code a controller
How to use the controller on the route is as follows:
- With Parameter To use the controller parameters on the way is also quite easy, just add a parameter to the constructor and when the controller is live input parameter constructor.
Next how to use at route as follow:
- With Method/Function For use method/function in controller is simple, just call in callback section route. Here's how to write the code controller using the method / function.
Next use method/function in route is as follow.
- With parameter in Method/Function For give paramter in Method/Fungsi in controller we can give at the time of the call method in callback route, The following code example controller with a method / function parameterized.
How to use in route as follow.
Middleware
top Middleware is functions will running before/after callback execution on route.
Model
top
For make model is simple, we just create a file with name as model name and save in directory that setting before via config, The following simple code model
How to use Model in controller are as follows.
View
top
For make view is also simple, because in this you don't need make class/object, but just plain php file will call by controller, the following code view.
How to use view file in controller are as follows.
How to send variable to view are as follows:
HMVC
Kecik Framework juga mendukung HMVC bahkan HMVC dengan struktur yang lebih dinamis. Contoh Struktur HMVC:
Controller dalam HMVC Untuk Controller pada HMVC penamaan namespace harus sama dengan struktur direktori MVC nya.
atau untuk HMVC Dinamis
Cara menggunakan controller HMVC pada route
Sedangkan untuk HMVC Dinamis
Model dalam HMVC Sama dengan Controller penamaan namespace harus sama dengan suktrur direktori MVC nya.
atau untuk HMVC Dinamis
Dan cara pemanggilannya pada controller adalah
atau untuk HMVC Dinamis
Kita bisa juga menggunakan Model dari module lain ataupun dari model utama yang berada diluar direktori module
View dalam HMVC Menggunakan file pada masing module tidak ada perbedaan dengan cara MVC, jadi kita tinggal memanggil nama file view nya tanpa disertakan dengan ekstensi .php
Sedangkan jika kita ingin menggunakan view dari module lain atau mungkin pada view utama yang berada diluar direktori module, kita cukup mengubah nilai pada parameter pertama menjadi array, dimana nilai index pertama adalah nama view jika ingin menggunakan view utama yang berada di luar direktori module, atau index pertama adalah nama module dan index kedua adalah nama view dari module yang view nya ingin digunakan.
atau
Url
top
Url is important for help jobs for get value like protocol, base path, base url, also redirect or make link to other route .
protocol()
For get Protocol value
basePath()
For get Base Path value
baseUrl()
For Get Base Url value
redirect($route)
For redirect to other route
to($route)
For echo url with route
linkTo($route)
For Get Url with Route value
Template
top
For make template in this framework is also simple, you just create template file in directory that you setting before via config. Here is a simple example of code templates
Sign
{{
dan}}
just subtitute tag<?php
and>
for echo you can use{{=
it's same<?php echo
while want using sign{{
and}}
for AngularJS you can use sign\
after its, example\{{
atau\}}
, this just simple template engine, but you use php tags.The
@response
atau@yield
is to put the output of the controller.The
@css
or@js
is to apply the template rendering assets
How to use the template on the route is as follows.
Replace Template