Closed ehsanquddusi closed 10 years ago
I am trying to use the package with my CodeIgniter project by following the instructions given in readme file.
I have created a class to initialize the connection & other settings. The contents of the class are:
use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Events\Dispatcher; use Illuminate\Container\Container; class Capsule extends CapsuleManager { function __construct() { $ci = &get_instance(); $db = $ci->db; $this->addConnection(array( 'driver' => $db->dbdriver, 'host' => $db->hostname, 'database' => $db->database, 'username' => $db->username, 'password' => $db->password, 'charset' => $db->char_set, 'collation' => $db->dbcollat, 'prefix' => $db->dbprefix, )); $this->setEventDispatcher(new Dispatcher(new Container)); // Make this Capsule instance available globally via static methods... (optional) $this->setAsGlobal(); // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher()) $this->bootEloquent(); } }
When I initiailze the above class, it gives me an error
Call to a member function instance() on a non-object
with stack trace to
\illuminate\database\Illuminate\Database\Capsule\Manager.php
at Line 216
public function setEventDispatcher(Dispatcher $dispatcher) { $this->container->instance('events', $dispatcher); //Line 216 }
My composer.json uses
composer.json
"illuminate/database": "@dev"
Don't override the constructor. You have not followed the instructions at all.
I am trying to use the package with my CodeIgniter project by following the instructions given in readme file.
I have created a class to initialize the connection & other settings. The contents of the class are:
When I initiailze the above class, it gives me an error
with stack trace to
at Line 216
My
composer.json
uses