CodeIgniter Forums
Codeigniter 4 using Eloquent - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Codeigniter 4 using Eloquent (/showthread.php?tid=76722)



Codeigniter 4 using Eloquent - kenobicode - 06-12-2020

Hello guys, howto install and use eloquent in codeigniter 4, this is important for me, thanks a lot


RE: Codeigniter 4 using Eloquent - Andy9166 - 07-03-2020

This works for me and has probably been copied and pasted from elsewhere):
Load eloquent libraries via composer
All my Eloquent Model classes are in app/Models/Eloquent folder
In app/Config/Database.php - at the end of the constructor:
        $capsule = new Capsule;

        $capsule->addConnection([
            'driver'    => 'mysql',
            'host'      => $this->default['hostname'],
            'database'  => $this->default['database'],
            'username'  => $this->default['username'],
            'password'  => $this->default['password'],
            'charset'  => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => $this->default['DBPrefix'],
        ]);

        // Set the event dispatcher used by Eloquent models... (optional)
        $capsule->setEventDispatcher(new Dispatcher(new Container));

        // Make this Capsule instance available globally via static methods... (optional)
        $capsule->setAsGlobal();

        // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
        $capsule->bootEloquent();
        //require each model file
        foreach(glob(APPPATH."/Models/Eloquent/*.php") as $file){
            require $file;
        }


RE: Codeigniter 4 using Eloquent - franciscofruiz - 07-06-2020

Check this Edit: https://faroti.com/blog/2020/07/06/how-to-integrate-laravel-eloquent-orm-in-codeigniter-4/


RE: Codeigniter 4 using Eloquent - marcogmonteiro - 07-07-2020

This link does not work.


RE: Codeigniter 4 using Eloquent - usmanikram - 07-07-2020

(07-07-2020, 01:34 AM)marcogmonteiro Wrote: This link does not work.

http://faroti.com/blog/2020/07/06/how-to-integrate-laravel-eloquent-orm-in-codeigniter-4/