This repository contains the CodeIgniter framework integrated with Illuminate Database (Eloquent ORM) which Laravel framework used.
CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task.
The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite. It also serves as the database layer of the Laravel PHP framework.
$ git clone https://github.com/jmprns/codeigniter-eloquent.git
$ cd codeigniter-eloquent
$ composer install
First, go to the application/config/database.php
to update your database credentials.
$eloquent['db'] = array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
);
You need to autoload the database library to instantiate the capsule manager. Go to the application/config/autoload.php
and type the database
in the array to look like this:
$autoload['libraries'] = array('database');
To set up the model, you can also autoload the model to access it without using the use path\to\model
method. The model should extend the eloquent class.
defined('BASEPATH') OR exit('No direct script access allowed');
use Illuminate\Database\Eloquent\Model as Eloquent;
class Test extends Eloquent
{
protected $guarded = [];
protected $table = "test";
public $timestamps = false;
}
For guides and manual of the Eloquent, you can go to the Laravel Eloquent.