---
title: "Ci4 Facades — Project Dossier | Isaac Machakata | Isaac Machakata"
description: "A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging"
canonical_url: "https://isaac.co.zw/projects/ci4-facades"
meta:
  author: "Isaac Munyaradzi Machakata"
  "og:description": "A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging"
  "og:image": "https://isaac.co.zw/_og/s/o_fc18f09008a05ad7.png"
  "og:image:alt": "Ci4 Facades — Project Dossier | Isaac Machakata"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Ci4 Facades — Project Dossier | Isaac Machakata"
  "twitter:description": "A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging"
  "twitter:image": "https://isaac.co.zw/_og/s/o_fc18f09008a05ad7.png"
  "twitter:image:alt": "Ci4 Facades — Project Dossier | Isaac Machakata"
  "twitter:title": "Ci4 Facades — Project Dossier | Isaac Machakata"
---

> Index of every page on this site: [llms.txt](https://isaac.co.zw/llms.txt)

[← Curriculum Vitae](https://isaac.co.zw/#projects)/ [ Projects](https://isaac.co.zw/projects) /#Ci4Facades

**open-source** Public Repo active ★ 1

# **Ci4 Facades**

Codename: **#Ci4Facades** · Repository: **immachakata/ci4-facades**

[Visit Live Deployment (packagist.org/packages/immachakata/ci4-facades)](https://packagist.org/packages/immachakata/ci4-facades) [View on GitHub](https://github.com/immachakata/ci4-facades)

Primary Language**PHP**

Last Updated**Nov 22, 2026**

Created**Nov 9, 2026**

Branch / Size**main · 33 KB**

## **Executive Summary **

A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging

## **GitHub Codebase Language Breakdown **

**PHP**100%

## **Repository Documentation (README.md) **

Fetched from GitHub

# CI4 Facades

[Permalink: CI4 Facades](#ci4-facades)

[![Packagist Version](https://camo.githubusercontent.com/1da726f75bc83dd53215ba10eb7e7286f6e8cc17e84366c50dc1af03d4c31f16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6d616368616b6174612f6369342d66616361646573)](https://camo.githubusercontent.com/1da726f75bc83dd53215ba10eb7e7286f6e8cc17e84366c50dc1af03d4c31f16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6d616368616b6174612f6369342d66616361646573) [![Packagist Downloads](https://camo.githubusercontent.com/94006b6be6c0235be573ac3b9aa0fec2588cd52a32b373debaa9d1f51e9ec24e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6d616368616b6174612f6369342d66616361646573)](https://camo.githubusercontent.com/94006b6be6c0235be573ac3b9aa0fec2588cd52a32b373debaa9d1f51e9ec24e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6d616368616b6174612f6369342d66616361646573) [![Packagist License](https://camo.githubusercontent.com/1d90d7880a617bb2242c77c365ba61990ae8274ae69eec32ed161db1f447eb16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d6d616368616b6174612f6369342d66616361646573)](https://camo.githubusercontent.com/1d90d7880a617bb2242c77c365ba61990ae8274ae69eec32ed161db1f447eb16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d6d616368616b6174612f6369342d66616361646573) A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging.

## Requirements

[Permalink: Requirements](#requirements)

- PHP >= 7.4 or 8.0+
- CodeIgniter 4.x

## Installation

[Permalink: Installation](#installation)

Install the package via Composer:

```
composer require immachakata/ci4-facades
```

## Usage

[Permalink: Usage](#usage)

### Migrations (`Schema` & `Ci4Facades` Trait)

Permalink: Migrations (Schema & Ci4Facades Trait)

You can use either the `Schema` facade directly or the `IsaacMachakata\Ci4Facades` trait inside your CodeIgniter 4 migration classes:

```
<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;
use IsaacMachakata\Ci4Facades;
use IsaacMachakata\Ci4Facades\Blueprint;
use IsaacMachakata\Ci4Facades\Schema;

class CreateUsersTable extends Migration
{
    use Ci4Facades;

    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down()
    {
        Schema::dropIfExists('users');
    }
}
```

Or using the trait helper methods (`$this->create()`, `$this->table()`, `$this->dropIfExists()`):

```
$this->create('posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('user_id')->constrained()->cascadeOnDelete();
    $table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
    $table->foreignId('author_id')->constrained('users'); // Custom table
    $table->foreignId('reviewer_id')->constrained('users', 'id', 'fk_posts_reviewer'); // Custom table, column & constraint name
    $table->string('title');
    $table->text('body')->nullable();
    $table->timestamps();
});
```

#### Modifying Tables & Columns (`change()`, `renameTo()`, Foreign Keys)

Permalink: Modifying Tables & Columns (change(), renameTo(), Foreign Keys)

Use `Schema::table()` (or `$this->table()` via the `Ci4Facades` trait) to add columns, modify existing columns with `->change()`, rename columns with `->renameTo()`, or add/drop foreign keys and indexes:

```
Schema::table('posts', function (Blueprint $table) {
    // Modify an existing column
    $table->string('title', 200)->nullable()->change();

    // Rename and modify an existing column
    $table->text('body')->renameTo('content')->nullable()->change();

    // Add a new constrained foreign key column
    $table->foreignId('organization_id')->nullable()->after('user_id')->constrained()->nullOnDelete();

    // Drop a constrained foreign key and its column
    $table->dropConstrainedForeignId('category_id');
});
```

#### Available `Blueprint` Column Methods

[Permalink: Available Blueprint Column Methods](#available-blueprint-column-methods)

- `$table->id('id')` / `$table->increments('id')`
- `$table->foreignId('user_id')->constrained()` / `$table->foreignUuid('tenant_id')->constrained()`
- `$table->string('name', 255)` / `$table->char('code', 10)` / `$table->uuid('uuid')`
- `$table->text('description')` / `$table->mediumText('summary')` / `$table->longText('content')`
- `$table->integer('votes')` / `$table->unsignedInteger('user_id')` / `$table->smallInteger('rank')` / `$table->unsignedSmallInteger('count')`
- `$table->bigInteger('views')` / `$table->unsignedBigInteger('user_id')`
- `$table->boolean('is_admin')` / `$table->tinyInteger('status')` / `$table->unsignedTinyInteger('level')`
- `$table->decimal('amount', 8, 2)` / `$table->float('rating', 8, 2)` / `$table->double('score', 8, 2)`
- `$table->date('birth_date')` / `$table->time('starts_at')` / `$table->dateTime('published_at')` / `$table->timestamp('logged_at')`
- `$table->timestamps()` / `$table->softDeletes()`
- `$table->json('options')` / `$table->enum('status', ['draft', 'published'])`
- Column modifiers: `->nullable()`, `->default($val)`, `->unsigned()`, `->unique()`, `->primary()`, `->index()`, `->comment('...')`, `->after('col')`, `->first()`, `->change()`, `->renameTo('new_name')`, `->constrained($table, $column, $name)`, `->references('id')`
- Foreign key actions: `->cascadeOnDelete()`, `->cascadeOnUpdate()`, `->nullOnDelete()`, `->restrictOnDelete()`, `->restrictOnUpdate()`, `->noActionOnDelete()`, `->noActionOnUpdate()`, `->onDelete('...')`, `->onUpdate('...')`, `->name('fk_name')`
- Table drop helpers: `->dropColumn('col')`, `->dropForeign(['user_id'])`, `->dropConstrainedForeignId('user_id')`, `->dropIndex('idx')`, `->dropUnique('idx')`, `->dropPrimary()`

### Logging (`Log` Facade)

[Permalink: Logging (Log Facade)](#logging-log-facade)

Instead of calling CodeIgniter's procedural `log_message('info', 'message')` helper, you can use the expressive `Log` facade:

```
use IsaacMachakata\Ci4Facades\Log;

// Instead of: log_message('info', 'User logged in');
Log::info('User logged in');

// Other log levels:
Log::error('Something went wrong');
Log::debug('Debugging payload data');
Log::warning('Disk space is running low');
Log::critical('Database connection failed');
```

### Database transactions (`DB` Facade)

[Permalink: Database transactions (DB Facade)](#database-transactions-db-facade)

Use `DB::transaction()` to commit when the callback completes successfully and roll back if it throws:

```
use App\Models\Users;
use IsaacMachakata\Ci4Facades\DB;

$users = model(Users::class);

DB::transaction(function () use ($users) {
    $users->insert(['name' => 'Ada']);
});
```

Use models as usual inside the callback. Their writes participate in the transaction when they use the same database connection as `DB::transaction()`. The callback may also accept the connection as an argument when you need to run queries directly, and its return value is returned by `transaction()`.

Alternatively, you can use the database connection passed to the callback:

```
DB::transaction(function ($db) {
    $db->table('users')->insert(['name' => 'Ada']);
});
```

Classes using the `Ci4Facades` trait can use the equivalent `$this->transaction()` helper:

```
$this->transaction(function () use ($users) {
    $users->insert(['name' => 'Ada']);
});
```

## Roadmap

[Permalink: Roadmap](#roadmap)

- Migration traits ( `use IsaacMachakata\Ci4Facades`)
- Logging facade ( `Log::info("message")`)
- Expressive `Schema` & `Blueprint` builder helpers
- Database transactions ( `DB::transaction()`)
- Additional CodeIgniter 4 service facades

## Contributing

[Permalink: Contributing](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.

## Author

[Permalink: Author](#author)

- **Isaac Machakata** - [hie@isaac.co.zw](mailto:hie@isaac.co.zw)

## License

[Permalink: License](#license)

This package is open-sourced software licensed under the [MIT license](https://github.com/immachakata/ci4-facades/blob/main/LICENSE.md).

## **Recent Repository Commits **

`1d83810`docs: update readme to reflect changes

Nov 22, 2026

`19c95d3`refactor: fix bug in pluralization

Nov 22, 2026

`d917cb0`refactor: add schema support for modify

Nov 22, 2026

`d43a37f`refactor: update with modify and drop helper

Nov 22, 2026

`e0c089f`refactor: add change method for modification of existing columns

Nov 22, 2026

### **Stack & Repository Topics **

**PHP** #codeigniter4 #codeigniter4-library #oss #portfolio

## **Related Work & Projects **

[All projects →](https://isaac.co.zw/projects)

### [Ci4 Relationships – PHP](https://isaac.co.zw/projects/ci4-relationships)

★ 3

[packagist.org/packages/immachakata/ci4-relationships](https://packagist.org/packages/immachakata/ci4-relationships "https://packagist.org/packages/immachakata/ci4-relationships")

Simple nested model relations for CodeIgniter 4 framework

#oss #portfolio

### [Codels Sms Php – PHP](https://isaac.co.zw/projects/codels-sms-php)

★ 2

[packagist.org/packages/immachakata/codelsms](https://packagist.org/packages/immachakata/codelsms "https://packagist.org/packages/immachakata/codelsms")

PHP wrapper for 2waychat.com bulk sms by sms.codel.tech

#2waychat-sms #bulk-sms #codel-sms

### [Free For.dev – HTML](https://isaac.co.zw/projects/free-for-dev)

[github.com/ripienaar/free-for-dev/pulls?q=is%3Apr+author%3Aimmachakata](https://github.com/ripienaar/free-for-dev/pulls?q=is%3Apr+author%3Aimmachakata "https://github.com/ripienaar/free-for-dev/pulls?q=is%3Apr+author%3Aimmachakata")

A list of SaaS, PaaS and IaaS offerings that have free tiers of interest to devops and infradev

#contribution #oss #portfolio

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://isaac.co.zw/#website","@type":"WebSite","name":"Isaac Machakata","url":"https://isaac.co.zw/"},{"@id":"https://isaac.co.zw/projects/ci4-facades#webpage","@type":"WebPage","description":"A lightweight PHP package for CodeIgniter 4 that brings clean, expressive, Laravel-like traits and facades to your project—starting with database migrations and logging","name":"Ci4 Facades — Project Dossier | Isaac Machakata","url":"https://isaac.co.zw/projects/ci4-facades","isPartOf":{"@id":"https://isaac.co.zw/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://isaac.co.zw/projects/ci4-facades"]}]}]}
```

## Sitemap

See the full [sitemap](https://isaac.co.zw/sitemap.md) for all pages.
