kobar / kobar-php
Kobar — PHP framework dengan syntax mirip JSX. Build HTML, CSS, dan JS langsung dari PHP.
dev-main
2026-08-22 05:30 UTC
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-05 23:53:54 UTC
README
PHP framework dengan syntax mirip JSX. Build HTML, CSS, dan JS langsung dari PHP — tanpa template engine, tanpa tulis JS manual.
Instalasi
composer require kobar/framework
Atau clone langsung:
git clone https://github.com/username/kobar.git
cd kobar
php serve
Cara Pakai
HTML Builder
$card = build::div([ build::h1("Judul"), build::p("Isi konten"), ]);
CSS Builder
$card->style([ 'background' => '#fff', 'padding' => '20px', 'border-radius' => '8px', ]); // Global style::body(['margin' => '0', 'font-family' => 'system-ui']);
Component
// components/Card.php class Card extends Component { public function build(): Node { return build::div([ build::h2($this->props['title']), ...$this->slots, ]); } } // Di view $card = component::card(['title' => 'Halo']); $card->children([build::p("Isi")]);
Global Element
// layouts/elements.php useElement::define('navbar', function() { return build::nav([build::span("🔥 Kobar")]); }); // Di view mana aja $navbar = useElement::navbar();
JS Actions — tanpa tulis JS
$btn->on('click', action::alert('Halo!')); $btn->on('click', action::toggleClass('open')); $btn->on('click', action::redirect('/login')); $btn->on('click', action::combine( action::prevent(), action::addClass('loading'), action::setText('Memuat...'), ));
Routing
// routes/web.php Router::get('/', 'home'); Router::get('/dashboard', 'dashboard', ['auth']); Router::get('/blog/:slug', 'blog.show');
Middleware
// middlewares/auth.php middleware::define('auth', function() { session_start(); if (!isset($_SESSION['user'])) { Router::redirect('/login'); } });
CLI
php kobar make:component NamaComponent php kobar make:view nama.view php kobar make:element namaElement php kobar make:middleware namaMiddleware php kobar list:components php kobar list:views php kobar list:elements php kobar list:routes php kobar list:middlewares
Struktur Folder
kobar/
├── core/ # Framework core
├── components/ # Reusable components
├── views/ # Halaman (.view.php)
├── layouts/ # Global elements
├── middlewares/ # Middleware
├── routes/ # Routing
├── config/ # Konfigurasi
├── kobar # CLI
└── index.php # Entry point
Requirements
- PHP >= 8.1
License
MIT