bbecker48 / codeigniter4-eloquent
Simple integration of Laravel Eloquent ORM into CodeIgniter 4 via Composer.
Package info
github.com/bbecker48/codeigniter4-eloquent
pkg:composer/bbecker48/codeigniter4-eloquent
Requires
- php: ^8.2
- codeigniter4/framework: ^4.5
- illuminate/database: ^12.0
README
Simple integration of the Laravel Eloquent ORM into CodeIgniter 4 via Composer.
The package automatically initializes Eloquent when a CodeIgniter application starts. No additional service or event configuration is required in your project.
Requirements
- PHP 8.2 or later
- CodeIgniter 4.5 or later
- MySQL or MariaDB
- Composer
Installation
From the root directory of your CodeIgniter 4 project, run:
composer require bbecker48/codeigniter4-eloquent
Eloquent and its dependencies will be installed automatically.
Database configuration
Configure your database connection in the CodeIgniter .env file:
database.default.hostname = localhost database.default.database = my_database database.default.username = root database.default.password = database.default.DBDriver = MySQLi
The package automatically uses the CodeIgniter database configuration to initialize Eloquent.
Create an Eloquent model
Create your models in app/Models.
Example:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Book extends Model { public $timestamps = false; }
You can then use Eloquent directly from your controllers:
use App\Models\Book; $book = Book::find(1); echo $book->title;
All standard Eloquent features can be used, including queries, relationships, collections and CRUD operations.
How it works
The package integrates illuminate/database with the CodeIgniter lifecycle and automatically boots Eloquent when the application starts.
You do not need to modify:
app/Config/Services.phpapp/Config/Events.php- your CodeIgniter core files
Documentation
License
This package is open-sourced software licensed under the MIT License.