Pusaka adalah sebuah Framework PHP yang powerfull. Memberikan developer kemudahan dalam membuat, mengedit dan memantain web application. Menggunakan konsep Modular serta Integrated Application Protocol untuk memudahkan proses editing file.
Pusaka Framework dilengkapi dengan fitur EasyUI Compiler yaitu fitur precompile template parser dengan code yang singkat dan indah.
<?php
use Pusaka\Hmvc\Controller;
class EasyuiCS extends Controller {
function index() {
}
function basic_usage() {
$title = "Pusaka Framework EasyUI";
$items = [
[
"id" => 1,
"age" => 21,
"name" => "foo"
], [
"id" => 2,
"age" => 23,
"name" => "bar"
]
];
// easyui-basic-usage.easyui.php
//------------------------------------------------------------------
$this->load->view( 'easyui-basic-usage', compact('title', 'items'));
}
}
<!DOCTYPE html>
<html>
<head>
<title><< $title >></title>
<head>
<body>
<table>
<thead>
<tr>
<th>Id<th>
<th>Age<th>
<th>Name<th>
<tr>
<thead>
<tbody>
@foreach( $items as $item )
<tr>
<td> << $item['id'] >> <td>
<td> << $item['age'] >> <td>
<td> << $item['name'] >> <td>
<tr>
@endforeach;
<tbody>
<table>
<body>
<html>
Pusaka Framework dilengkapi dengan fitur MetaDocument yaitu fitur routing dan dokumentasi dengan menggunakan comment pada class dan method.
<?php
use Pusaka\Hmvc\Controller;
/**
* @middleware example
*/
class MetadocumentCS extends Controller {
function index() {
$var = $this->load->var;
$c = $var['a'] + $var['b'];
// metadocument.ui.php
//------------------------------------------------------------------
$this->load->view( NULL, compact('c') );
}
}
$a + $b = << $c >>
<?php
use Pusaka\Http\Middleware;
use Pusaka\Core\Loader;
class ExampleMiddleware extends Middleware {
public function begin(Loader $loader) {
$loader->add([
'a' => 1,
'b' => 3
]);
}
public function end() {
}
}
Pusaka Framework dilengkapi dengan fitur RestApi sebuah microframework yang ringan sehingga menghasilkan response yang tercepat.
<?php
use Pusaka\Hmvc\Controller;
use Pusaka\Http\Request;
use Pusaka\Http\HttpClient;
class RestapiCS extends Controller {
function index() {
$example = [];
HttpClient::get([
'url' => url('api/example/restapi'),
'success' => function($respone) use ( &$example ) {
$example = json_decode($respone);
}
]);
// restapi.ui.php
//------------------------------------------------------------------
$this->load->view( NULL, compact('example') );
}
}
@d( $example )
<?php
use Pusaka\Core\Loader;
$app->post('restapi', ['middleware' => 'example',
function(Loader $load) {
$response = [
'vars' => $load->var,
'foo',
'bar'
];
return $response;
}
]);