Thursday, February 26, 2026

Steps to set up a Modules directory in CI 4

 To add a modules directory in CodeIgniter 4, you need to create the directory in your project's root and configure the autoloader to recognize a new namespace for it. This allows you to organize application components into modular, self-contained units.

Steps to set up a Modules directory
  1. Create the Modules directory: In your project's root directory (alongside the apppublic, and system folders), create a new folder named Modules (or modules, but capitalization must be consistent).
  2. Configure Autoloading: Open the app/Config/Autoload.php file and add the Modules namespace to the $psr4 array.
    php
    // In app/Config/Autoload.php
    
    public $psr4 = [
        APP_NAMESPACE => APPPATH, // For custom namespace
        'App'         => APPPATH, // To ensure filters, etc still found,
        'Config'      => APPPATH . 'Config',
        'Modules'     => ROOTPATH . 'Modules', // Add this line
    ];
    
    Note: ROOTPATH refers to your project's root directory.
  3. Create a sample module structure: Inside the Modules folder, create a directory for your specific module (e.g., Blog). Inside the Blog module folder, you can mirror the structure of the main app folder with its own ControllersModelsViewsConfig, etc..Example structure:
    /
    ├── app/
    ├── public/
    ├── system/
    ├── Modules/
    │   ├── Blog/
    │   │   ├── Config/
    │   │   ├── Controllers/
    │   │   │   └── Blog.php
    │   │   ├── Models/
    │   │   └── Views/
    ...
    
  4. Define a Controller with the correct namespace: In your module's controller file (e.g., Modules/Blog/Controllers/Blog.php), ensure the namespace matches your configuration.
    php
    <?php namespace Modules\Blog\Controllers;
    
    use App\Controllers\BaseController;
    
    class Blog extends BaseController
    {
        public function index()
        {
            echo 'Hello from the Blog Module!';
        }
    }
    
  5. Set up Routing: You can define routes for your module in app/Config/Routes.php or create a separate routes file within the module itself that is automatically discovered. To use module-level routes, you must ensure the main application's route file is set to discover them, and define the routes with the full namespace in the module's Config/Routes.php file.For a simple route in app/Config/Routes.php to the example above:
    php
    $routes->get('/blog', 'Modules\Blog\Controllers\Blog::index');
    
For detailed official documentation on Code Modules and auto-discovery, refer to the CodeIgniter User Guide

Routing dan Controller pada CI 4

Routing dan Controller di CodeIgniter 4 (CI4) bekerja sama menangani HTTP Request. Routes (app/Config/Routes.php) memetakan URL ke Controller, sedangkan Controller (di app/Controllers) berisi logika aplikasi untuk memproses request dan mengembalikan respons (View/JSON). CI4 mendukung rute manual, auto-routing, dan RESTful API.

Routing pada CI4
  • Definisi: app/Config/Routes.php adalah file utama untuk mengatur rute.
  • Contoh: $routes->get('/user', 'UserController::index'); mengarahkan URL /user ke method index di UserController.
  • Parameter: Digunakan untuk dinamis, contoh: $routes->get('user/(:num)', 'UserController::show/$1');.
Controller pada CI4
  • Lokasi: Disimpan di app/Controllers.
  • Struktur: Class PHP yang mewarisi CodeIgniter\Controller.
  • Fungsi: Mengambil input, berinteraksi dengan Model, dan menampilkan View.
php
// Contoh Controller: app/Controllers/Product.php
namespace App\Controllers;

class Product extends BaseController
{
    public function index()
    {
        return view('product_view'); // Menampilkan view
    }
}
Jenis Rute Lainnya
  • Auto Routing: CI4 otomatis mencocokkan URL dengan controller/method tanpa didefinisikan satu per satu.
  • Resource Routes: Memudahkan CRUD dengan $routes->resource('photo'); yang memetakan banyak method (index, create, show, dll) sekaligus.

Tuesday, February 24, 2026

Info Ringkas Laravel 12

Laravel 12 adalah versi terbaru (rilis 24 Februari 2025), menghadirkan peningkatan performa, starter kit modern (Shadcn, Flux), dan integrasi autentikasi WorkOS yang lebih baik. Fokus pada stabilitas dan pengembangan aplikasi web modern, Laravel 12 mendukung PHP versi terbaru, serta mempermudah migrasi menggunakan Laravel Shift.

Fitur dan Pembaruan Utama Laravel 12 (Februari 2025):
  • Struktur Starter Kit Modern: Mendukung komponen UI modern seperti Shadcn dan Flux untuk integrasi lebih mudah dengan React, Vue, dan Livewire.
  • Peningkatan Autentikasi: Integrasi WorkOS AuthKit untuk SSO, passkeys, dan social login.
  • Pembaruan Dependensi & Performa: Optimalisasi untuk aplikasi modern dan scalable.
  • Laravel Shift: Mempermudah proses upgrade dan memastikan kompatibilitas paket pihak ketiga.
  • Ekosistem Terintegrasi: Dukungan penuh untuk tools seperti Laravel Breeze & JetstreamPulse, dan Reverb.
Sebelumnya, Laravel 11 (dirilis Maret 2024) membawa perubahan struktur folder yang lebih minimalis dan SQLite sebagai default database.

Monday, February 23, 2026

Membuat beckend di google apps script

Membuat backend dengan Google Sheet melibatkan penggunaan Google Sheets sebagai database dan Google Apps Script (GAS) sebagai serverless backend untuk mengolah data (CRUD: Create, Read, Update, Delete) melalui API. Anda bisa membuat aplikasi sederhana tanpa coding via AppSheet atau membuat REST API khusus menggunakan Apps Script untuk terhubung dengan frontend web/aplikasi.
Berikut langkah-langkah membuat backend sederhana dengan Google Sheets dan Apps Script:
1. Persiapan Database (Google Sheets)
  • Buat spreadsheet baru dan berikan nama judul kolom pada baris pertama (misal: ID, Nama, Pesan, Tanggal).
  • Isi beberapa data contoh.
  • Buka menu Ekstensi > Apps Script.

Sunday, February 22, 2026

Klasifikasi pemrograman Java

 Klasifikasi pemrograman Java terbagi menjadi tiga edisi utama—Java SE (Standard Edition)EE (Enterprise Edition), dan ME (Micro Edition)—berdasarkan fungsi dan perangkatnya. Java adalah bahasa object-oriented (PBO), statically typed, dan portable ("Write Once, Run Anywhere") yang menggunakan JVM untuk menjalankan bytecode.

Quiz Pengetahuan Bahasa Pemrograman

Quiz

Saturday, February 21, 2026

Membuat Dropdown Menu pada Blogger

 To restructure an HTML list in JavaScript by making certain li elements a child of another li based on a specific character, you can iterate through the list items and use DOM manipulation methods like appendChild().

JavaScript Code Example
This example assumes the li elements to be nested contain a specific character (e.g., '-') at the beginning of their text content, and should be nested under the preceding li that does not have the character.
javascript
function nestListItems(ulSelector, markerChar) {
    const ul = document.querySelector(ulSelector);
    if (!ul) return;

    // Select all direct child li elements of the ul
    const items = Array.from(ul.children);
    let parentItem = null;

    items.forEach(item => {
        // Check if the current li contains the specific character
        if (item.textContent.trim().startsWith(markerChar)) {
            // If a parent li has been established, move the current item into it
            if (parentItem) {
                // Remove the item from its current position in the DOM
                ul.removeChild(item); 
                
                // Create a new nested ul if one doesn't exist in the parent
                let nestedUl = parentItem.querySelector('ul');
                if (!nestedUl) {
                    nestedUl = document.createElement('ul');
                    parentItem.appendChild(nestedUl);
                }
                
                // Append the current item (which is now a new node) to the nested ul
                nestedUl.appendChild(item);
                                Array.from(nestedUl.children).forEach(itemtext =&gt; {
      		    itemtext.querySelector(&#39;a&#39;).innerHTML=itemtext.textContent.substring(2);
      				
      		 });
            }
        } else {
            // If it doesn't have the marker, it becomes a potential new parent
            parentItem = item;
        }
    });
}

// Usage: Call the function for your specific UL and marker
nestListItems('#myList', '-');