Sistem Berbasis Website

Contoh Aplikasi Chat Realtime dengan Ratchet, MySQL, Bootstrap, CSS, dan CodeIgniter 4

Tutorial membuat aplikasi chat realtime CodeIgniter 4 menggunakan Ratchet WebSocket, MySQL, Bootstrap, CSS, dan JavaScript lengkap dengan source code.

Contoh coding Contoh Aplikasi Chat Realtime dengan Ratchet, MySQL, Bootstrap, CSS, dan CodeIgniter 4
Langkah 5 dari 12

Membuat Konfigurasi Chat

Buat app/Config/Chat.php. Karena nilai berasal dari .env, pengaturan lokal dan produksi dapat berbeda tanpa mengubah source code:

class Chat extends BaseConfig
{
    public string $websocketHost;
    public int $websocketPort;
    public string $websocketUrl;
    public string $allowedOrigin;

    public function __construct()
    {
        parent::__construct();
        $this->websocketHost = (string) env('chat.websocketHost', '0.0.0.0');
        $this->websocketPort = (int) env('chat.websocketPort', 8081);
        $this->websocketUrl = (string) env('chat.websocketUrl', 'ws://localhost:8081');
        $this->allowedOrigin = (string) env('chat.allowedOrigin', 'http://localhost:8080');
    }
}