PHPackages                             ibroid/ci3-htmx-component - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ibroid/ci3-htmx-component

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ibroid/ci3-htmx-component
=========================

Mini Livewire-style HTMX component system for CodeIgniter 3

02PHP

Since Jul 4Pushed 10mo agoCompare

[ Source](https://github.com/ibroid/ci3-htmx-component)[ Packagist](https://packagist.org/packages/ibroid/ci3-htmx-component)[ RSS](/packages/ibroid-ci3-htmx-component/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CI3 HTMX Component
==================

[](#ci3-htmx-component)

Mini framework Livewire-like untuk CodeIgniter 3 menggunakan HTMX with Painless javascript. Support stateful components, nested component, action dll.

🚀 Fitur
-------

[](#-fitur)

- Component-based rendering
- Stateful viewmodel
- Full HTMX kompitable
- Nested component support
- CSRF + session-aware

---

📦 Instalasi
-----------

[](#-instalasi)

### 1. Tambahkan ke composer.json (jika lokal)

[](#1-tambahkan-ke-composerjson-jika-lokal)

```
composer require ibroid/ci3-htmx-component:dev-master
```

### 2. Aktifkan autoload di CodeIgniter 3

[](#2-aktifkan-autoload-di-codeigniter-3)

Edit `application/config/config.php`:

```
$config['composer_autoload'] = FCPATH . 'vendor/autoload.php';
```

### 3. Salin file view wrapper

[](#3-salin-file-view-wrapper)

Copy `views/components/_wrapper.php` dari package ini ke:

```
application/views/components/_wrapper.php

```

### 4. Tambahkan routing controller

[](#4-tambahkan-routing-controller)

Buat class controller dibawah ini:

```
// controllers/Htmx_action.php
use use CI3Htmx\Controller\HtmxAction;
class Htmx_action extends CI3Htmx\Controller\HtmxAction {}

// controllers/Htmx_component.php
use CI3Htmx\Controller\HtmxComponent;
class Htmx_component extends HtmxComponent {};
```

---

📄 Contoh Penggunaan
-------------------

[](#-contoh-penggunaan)

### 1. Buat komponen: `Counter.php`

[](#1-buat-komponen-counterphp)

```
namespace App\Components;

use CI3Htmx\Component;

class Counter extends Component
{
  public $count = 0;

  public function increment()
  {
    $this->count++;
  }

  public function render(): string
  {
    $this->initIds();

    return $this->renderWrapper(
      $this->renderContent()
    );
  }

  public function renderContent(): string
  {
    return $this->view('components/counter', [
      'count' => $this->count
    ]);
  }
}
```

### 2. View komponen: `application/views/components/counter.php`

[](#2-view-komponen-applicationviewscomponentscounterphp)

```

  Jumlah:
