Codeigniter 4 using Eloquent |
Hello guys, howto install and use eloquent in codeigniter 4, this is important for me, thanks a lot
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; }
Check this Edit: https://faroti.com/blog/2020/07/06/how-t...igniter-4/
This link does not work.
Website: marcomonteiro.net | Blog: blog.marcomonteiro.net | Twitter: @marcogmonteiro | TILThings: tilthings.com
(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/ |
Welcome Guest, Not a member yet? Register Sign In |