Codeigniter knowledge

From dykyi-roman/awesome-claude-code · View interactive version

Codeigniter knowledge is an AI agent skill from the GitHub repository dykyi-roman/awesome-claude-code. CodeIgniter 4 framework knowledge base. Provides CI4 MVC architecture, DDD integration, persistence, services, security (Shield auth, Filters authorization, CSRF), event system, queue (codeigniter4/queue jobs, workers, retry), infrastructure components (cache, HTTP client, email, throttler), testing

How to use this skill

Skill file

CodeIgniter Knowledge Base

Quick reference for CodeIgniter 4 framework patterns and PHP implementation guidelines. CodeIgniter 4 is a complete rewrite of the framework, built for PHP 8.1+ with namespaces, autoloading, and a modern MVC architecture. It remains lightweight and fast while providing the tools needed for professional application development.

Core Principles

MVC Architecture

Request → index.php → Bootstrap → Routing
  → Filters (before) → Controller → Service/Model → View
  → Filters (after) → Response

Key principles:

Quick Checklists

DDD-Compatible CI4 Project

Clean Architecture Checks

Common Violations Quick Reference

| Violation | Where to Look | Severity |

|-----------|---------------|----------|

| Business logic in Controller | app/Controllers/*.php | Critical |

| Domain depends on CI4 framework | use CodeIgniter\ in Domain classes | Critical |

| Direct DB queries in Controller | $this->db-> in Controllers | Critical |

| Model contains business rules | Complex if/switch in Model methods | Warning |

| Missing input validation | Controllers without $this->validate() | Warning |

| God Controller | Controllers > 300 lines | Warning |

| Shield UserIdentity in Domain | use CodeIgniter\Shield in Domain layer | Critical |

| Queue in Domain | service('queue') in Domain layer | Critical |

| Cache/HTTP Client in Domain | CacheInterface or CURLRequest in Domain | Critical |

| Missing queue resilience | Jobs without $retryAfter/$tries | Warning |

| Hardcoded config values | Magic strings instead of config() | Info |

PHP 8.4 CodeIgniter Patterns

Controller (Thin, Delegates to Service)

<?php
declare(strict_types=1);
namespace App\Controllers\Api;

use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;

final class OrderController extends BaseController
{
    public function __construct(
        private readonly OrderService $orderService,
    ) {}

    public function show(string $id): ResponseInterface
    {
        $order = $this->orderService->findById($id);
        return $this->response->setJSON(['id' => $order->id, 'status' => $order->status->value]);
    }
}

Service (Application Layer)

<?php
declare(strict_types=1);
namespace App\Services;

final readonly class OrderService
{
    public function __construct(
        private OrderRepositoryInterface $orders,
        private EventDispatcherInterface $events,
    ) {}

    public function confirm(string $orderId): void
    {
        $order = $this->orders->findById($orderId)
            ?? throw new OrderNotFoundException($orderId);
        $order->confirm();
        $this->orders->save($order);
        $this->events->dispatch(new OrderConfirmedEvent($order->id()));
    }
}

Model as Repository Adapter

<?php
declare(strict_types=1);
namespace App\Models;

use CodeIgniter\Model;

final class OrderModel extends Model
{
    protected $table         = 'orders';
    protected $primaryKey    = 'id';
    protected $returnType    = OrderEntity::class;
    protected $allowedFields = ['customer_id', 'status', 'total', 'notes'];
    protected $useTimestamps = true;
}

References

For detailed information, load these reference files:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.