本文整理汇总了PHP中Illuminate\Database\Capsule\Manager::setEventDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::setEventDispatcher方法的具体用法?PHP Manager::setEventDispatcher怎么用?PHP Manager::setEventDispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Capsule\Manager
的用法示例。
在下文中一共展示了Manager::setEventDispatcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
$this->capsule = new Capsule();
$this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
$this->capsule->setEventDispatcher(new Dispatcher(new Container()));
$this->capsule->setAsGlobal();
}
示例2: bootstrap
/**
* {@inheritdoc}
*/
public function bootstrap($app)
{
$this->capsule = new Manager();
$this->capsule->addConnection(['driver' => $this->driver, 'host' => $this->host, 'database' => $this->database, 'username' => $this->username, 'password' => $this->password, 'charset' => $this->charset, 'collation' => $this->collation, 'prefix' => $this->prefix]);
$this->capsule->setEventDispatcher(new Dispatcher(new Container()));
$this->capsule->setAsGlobal();
$this->capsule->bootEloquent();
$app->set('db', $this->capsule);
}
示例3: __construct
public function __construct()
{
$capsule = new Capsule();
$capsule->addConnection(["driver" => "mysql", "host" => "localhost", "database" => "development", "username" => "developer", "password" => "developer", "charset" => "utf8", "collation" => "utf8_general_ci", "prefix" => ""]);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->bootEloquent();
}
示例4: __construct
public function __construct()
{
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'designpatternscourse', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '']);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->bootEloquent();
}
示例5: register
public function register(Application $app)
{
$app['db'] = $app->share(function () use($app) {
$capsule = new Capsule();
if (!isset($app['i_db.config'])) {
throw new \InvalidArgumentException('i_db.config is required.');
}
$db['config'] = $app['i_db.config'];
if (!is_array($db)) {
throw new \InvalidArgumentException('$app[\'i_db.config\'] must is array;');
}
$capsule->addConnection($db['config']);
$db['i_db.event_dispatcher'] = isset($app['i_db.event_dispatcher']) ? $app['i_db.event_dispatcher'] : true;
$db['i_db.global'] = isset($app['i_db.global']) ? $app['i_db.global'] : true;
$db['i_db.boot_eloquent'] = isset($app['i_db.boot_eloquent']) ? $app['i_db.boot_eloquent'] : true;
if ($db['i_db.event_dispatcher']) {
$capsule->setEventDispatcher(new Dispatcher(new Container()));
}
if ($db['i_db.global']) {
$capsule->setAsGlobal();
}
if ($db['i_db.event_dispatcher'] or $db['i_db.boot_eloquent']) {
$capsule->bootEloquent();
}
return $capsule;
});
}
示例6: register
/**
* Register the service provider.
*/
public function register()
{
$manager = new Manager();
$manager->addConnection($this->app->config->get('database')['default']);
$manager->setEventDispatcher(new Dispatcher());
$manager->setAsGlobal();
$manager->bootEloquent();
}
示例7: prepareDatabase
public static function prepareDatabase()
{
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'geo', 'username' => 'root', 'password' => 'iGlL]m1B', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '']);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
示例8: configureDatabase
/**
* Configure in memory database.
*/
protected function configureDatabase()
{
$db = new DB();
$db->addConnection(array('driver' => 'sqlite', 'database' => ':memory:', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ''));
$db->setEventDispatcher(new Dispatcher(new Container()));
$db->bootEloquent();
$db->setAsGlobal();
}
示例9: connectToDatabase
public static function connectToDatabase($hostname, $database, $username, $password)
{
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'mysql', 'host' => $hostname, 'database' => $database, 'username' => $username, 'password' => $password, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
示例10: configureDB
public function configureDB(array $options)
{
$capsule = new Capsule();
$capsule->addConnection($options);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
$this->dbConnected = true;
}
示例11: __construct
public function __construct()
{
$capsule = new Capsule();
$config = C("db");
$capsule->addConnection(['driver' => $config['type'], 'host' => $config['host'], 'database' => $config['database'], 'username' => $config['username'], 'password' => $config['password'], 'charset' => $config['charset'], 'collation' => $config['collation'], 'prefix' => $config['prefix']]);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'pgsql', 'host' => 'localhost', 'database' => 'datoum', 'username' => 'jerome', 'password' => '', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public']);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
示例13: initDb
protected function initDb(Capsule $capsule)
{
global $dbCreds;
$capsule->addConnection($dbCreds);
$capsule->setEventDispatcher(new Dispatcher());
$capsule->setAsGlobal();
$capsule->bootEloquent();
return $capsule;
}
示例14: setup
/**
* Setup all the illuminate magic
*
* @return $this
*/
public function setup()
{
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'mysql', 'host' => getenv('mysql.hostname'), 'database' => getenv('mysql.database'), 'username' => getenv('mysql.username'), 'password' => getenv('mysql.password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
$capsule->setAsGlobal();
$capsule->bootEloquent();
return $this;
}
示例15: addConnection
public static function addConnection()
{
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'pgsql', 'host' => 'localhost', 'database' => 'instaclone', 'username' => 'postgres', 'password' => 'pass', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
// 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();
}