protected function configureDatabase() { $db = new DB(); $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $db->bootEloquent(); $db->setAsGlobal(); }
/** * @return DB */ public function setUpDatabase() { $db = new DB(); $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $db->setAsGlobal(); $db->bootEloquent(); }
/** * Set up the database connection. * * @before * @return void */ protected function configureDatabaseConnection() { $database = new DB(); $database->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']); $database->bootEloquent(); $database->setAsGlobal(); }
public function register(Application $app) { $app['illuminate.db.default_options'] = array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => 'password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ''); $app['illuminate.db'] = $app->share(function ($app) { return $app['illuminate.capsule']->getConnection($app['illuminate.db.default_connection']); }); $app['illuminate.db.options.initializer'] = $app->protect(function () use($app) { if (!isset($app['illuminate.db.options'])) { $app['illuminate.db.options'] = array('default' => array()); } $tmp = $app['illuminate.db.options']; foreach ($tmp as $name => &$options) { $options = array_replace($app['illuminate.db.default_options'], $options); if (!isset($app['illuminate.db.default_connection'])) { $app['illuminate.db.default_connection'] = $name; } } $app['illuminate.db.options'] = $tmp; }); $app['illuminate.capsule'] = $app->share(function ($app) { $app['illuminate.db.options.initializer'](); $capsule = new Manager(); foreach ($app['illuminate.db.options'] as $name => $options) { $capsule->addConnection($options, $name); } return $capsule; }); }
public function init() { $this->capsule = new Capsule(); $this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'port' => DB_PORT, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => DB_CHARSET, 'collation' => DB_COLLATION]); $this->capsule->bootEloquent(); $this->capsule->setAsGlobal(); }
/** * @param MvcEvent $event */ public function onBootstrap(MvcEvent $event) { $eventManager = $event->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $event->getApplication(); $serviceManager = $app->getServiceManager(); // Set the Query Profiler $profiler = new DoplioFirePhpProfiler(); $capsule = new Capsule(); $config = $serviceManager->get('config')['database']; foreach ($config as $connName => $dbConfig) { $capsule->addConnection($dbConfig, $connName); if (isset($dbConfig['profiler']) && $dbConfig['profiler'] === TRUE) { $profiler->enable(); } } // $capsule->setCacheManager(); $capsule->bootEloquent(); $serviceManager->setService('Doplio', $capsule); $serviceManager->setService('DoplioFirePhpProfiler', $profiler); $eventManager->attach(MvcEvent::EVENT_FINISH, function () use($capsule, $config, $profiler) { if ($profiler->isDisabled()) { return; } foreach ($config as $connectionName => $notUsed) { $connection = $capsule->getConnection($connectionName); foreach ($connection->getQueryLog() as $query) { $profiler->addQuery($query, $connectionName); } } $profiler->showTables(); }); }
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(); }
/** * Initialize the Eloquent ORM. * */ public static function start() { $capsule = new Capsule(); $capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASS, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false]); $capsule->setAsGlobal(); $capsule->bootEloquent(); }
/** * Initializes the Eloquent ORM. */ public function initialize() { $this->capsule->bootEloquent(); if ('default' !== $this->defaultConnection) { $this->capsule->getDatabaseManager()->setDefaultConnection($this->defaultConnection); } }
public function register(Application $app) { $app['illuminate.db.default_options'] = (require $app['base_dir'] . '/backend/config/database.php'); $app['illuminate.db'] = $app->share(function ($app) { return $app['illuminate.capsule']->getConnection($app['illuminate.db.default_connection']); }); $app['illuminate.db.options.initializer'] = $app->protect(function () use($app) { if (!isset($app['illuminate.db.options'])) { $app['illuminate.db.options'] = array('default' => array()); } $tmp = $app['illuminate.db.options']; foreach ($tmp as $name => &$options) { $options = array_replace($app['illuminate.db.default_options'], $options); if (!isset($app['illuminate.db.default_connection'])) { $app['illuminate.db.default_connection'] = $name; } } $app['illuminate.db.options'] = $tmp; }); $app['illuminate.capsule'] = $app->share(function ($app) { $app['illuminate.db.options.initializer'](); $capsule = new Manager(); foreach ($app['illuminate.db.options'] as $name => $options) { $capsule->addConnection($options, $name); } return $capsule; }); }
/** * {@inheritdoc} */ public function register(Application $app) { $app['application.speakers'] = $app->share(function ($app) { $userMapper = $app['spot']->mapper(\OpenCFP\Domain\Entity\User::class); $talkMapper = $app['spot']->mapper(\OpenCFP\Domain\Entity\Talk::class); $speakerRepository = new SpotSpeakerRepository($userMapper); return new Speakers(new CallForProposal(new \DateTime($app->config('application.enddate'))), new SentryIdentityProvider($app['sentry'], $speakerRepository), $speakerRepository, new SpotTalkRepository($talkMapper), new EventDispatcher()); }); $app[AirportInformationDatabase::class] = $app->share(function ($app) { $capsule = new Capsule(); $capsule->addConnection(['driver' => 'mysql', 'host' => $app->config('database.host'), 'database' => $app->config('database.database'), 'username' => $app->config('database.user'), 'password' => $app->config('database.password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']); $capsule->setAsGlobal(); return new IlluminateAirportInformationDatabase($capsule); }); $app['security.random'] = $app->share(function ($app) { return new PseudoRandomStringGenerator(new Factory()); }); $app['oauth.resource'] = $app->share(function ($app) { $sessionStorage = new SessionStorage(); $accessTokenStorage = new AccessTokenStorage(); $clientStorage = new ClientStorage(); $scopeStorage = new ScopeStorage(); $server = new ResourceServer($sessionStorage, $accessTokenStorage, $clientStorage, $scopeStorage); return $server; }); $app['application.speakers.api'] = $app->share(function ($app) { $userMapper = $app['spot']->mapper(\OpenCFP\Domain\Entity\User::class); $talkMapper = $app['spot']->mapper(\OpenCFP\Domain\Entity\Talk::class); $speakerRepository = new SpotSpeakerRepository($userMapper); return new Speakers(new CallForProposal(new \DateTime($app->config('application.enddate'))), new OAuthIdentityProvider($app['oauth.resource'], $speakerRepository), $speakerRepository, new SpotTalkRepository($talkMapper), new EventDispatcher()); }); }
public static function boot() { require BASE_PATH . '/vendor/autoload.php'; $capsule = new Capsule(); $capsule->addConnection(Config::get('database.connections.' . Config::get('database.default'))); $capsule->bootEloquent(); }
private function setUpDatabases() { $database = new DB(); $database->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $database->bootEloquent(); $database->setAsGlobal(); }
/** * Setup eloquent database * @param \Illuminate\Database\Capsule\Manager $capsule * @throws \Lassi\App\Exception\NotFoundException * @return \Lassi\App\Database */ private function _makeEloquent(Capsule $capsule) { // Throw exception if minimum requirements not met if (!getenv('db_driver') || !getenv('db_name')) { throw new NotFoundException('App configurations not found.'); } // Get capsule instance $this->capsule = $capsule; // Cache db driver $db_driver = getenv('db_driver'); // Setup connection defaults $configs = array('driver' => $db_driver, 'database' => getenv('db_name'), 'prefix' => getenv('db_prefix'), 'charset' => getenv('db_charset'), 'collation' => getenv('db_collation')); // Add extras depending on type of driver/connection if ($db_driver !== 'sqlite') { if (getenv('db_host')) { $configs['host'] = getenv('db_host'); } if (getenv('db_username')) { $configs['username'] = getenv('db_username'); } if (getenv('db_password')) { $configs['password'] = getenv('db_password'); } } // Setup connection $this->capsule->addConnection($configs); // Set as global $this->capsule->setAsGlobal(); // Boot eloquent $this->capsule->bootEloquent(); return $this; }
public function register() { $this->app->singleton('laravel.db', function ($app) { $config = $app['config']; // Get the default database from the configuration $default = $config['database.default']; // Create an capsule instance $capsule = new CapsuleManager($app); // Override the default value with the user's config value $config['database.default'] = $default; if (!isset($config['database.connections']) || empty($config['database.connections'])) { throw new ConfigurationException("Invalid database configuration"); } $connections = $config['database.connections']; foreach ($connections as $name => $connectionConfig) { $capsule->addConnection($connectionConfig, $name); } $capsule->setAsGlobal(); // Setup the Eloquent ORM... if ($config['eloquent.boot'] === true) { $capsule->bootEloquent(); } return $capsule->getDatabaseManager(); }); }
public function setUp() { parent::setUp(); Eloquent::unguard(); $this->faker = Faker\Factory::create(); $db = new DB(); $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $db->bootEloquent(); $db->setAsGlobal(); $this->schema()->create('users', function ($table) { $table->increments('id'); $table->string('email'); $table->string('name'); $table->string('billing_id')->nullable(); $table->text('billing_cards')->nullable(); $table->text('billing_discounts')->nullable(); $table->tinyInteger('billing_active')->default(0); $table->string('billing_subscription')->nullable(); $table->tinyInteger('billing_free')->default(0); $table->string('billing_plan', 25)->nullable(); $table->integer('billing_amount')->default(0); $table->string('billing_interval')->nullable(); $table->integer('billing_quantity')->default(0); $table->string('billing_card')->nullable(); $table->timestamp('billing_trial_ends_at')->nullable(); $table->timestamp('billing_subscription_ends_at')->nullable(); $table->text('billing_subscription_discounts')->nullable(); $table->timestamps(); }); }
public function bootDb() { // Init Eloquent ORM Connection $capsule = new Capsule(); $capsule->addConnection(Config::getDbConfig()); $capsule->bootEloquent(); }
public function setUp() { Eloquent::unguard(); $db = new DB(); $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $db->bootEloquent(); $db->setAsGlobal(); $this->schema()->create('users', function ($table) { $table->increments('id'); $table->string('email'); $table->string('name'); $table->string('stripe_id')->nullable(); $table->string('card_brand')->nullable(); $table->string('card_last_four')->nullable(); $table->timestamps(); }); $this->schema()->create('subscriptions', function ($table) { $table->increments('id'); $table->integer('user_id'); $table->string('name'); $table->string('stripe_id'); $table->string('stripe_plan'); $table->integer('quantity'); $table->timestamp('trial_ends_at')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamps(); }); }
/** * Connect to the Wordpress database * * @param array $params */ public static function connect(array $params) { $capsule = new Capsule(); $params = array_merge(static::$baseParams, $params); $capsule->addConnection($params); $capsule->bootEloquent(); }
public static function init() { $db = new DB(); $db->addConnection(parse_ini_file('db.ini')); $db->setAsGlobal(); $db->bootEloquent(); }
public function setUp() { Eloquent::unguard(); $db = new DB(); $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $db->bootEloquent(); $db->setAsGlobal(); $this->schema()->create('users', function ($table) { $table->increments('id'); $table->string('email'); $table->string('first_name'); $table->string('last_name'); $table->timestamps(); }); $this->schema()->create('subscriptions', function ($table) { $table->increments('id'); $table->string('subscription_id'); $table->string('plan_id'); $table->integer('user_id')->index()->unsigned(); $table->integer('quantity')->default(1); $table->integer('last_four')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamp('trial_ends_at')->nullable(); $table->timestamp('next_billing_at')->nullable(); $table->timestamps(); }); $this->schema()->create('addons', function ($table) { $table->increments('id'); $table->integer('subscription_id')->index()->unsigned(); $table->string('addon_id'); $table->integer('quantity')->default(0); $table->timestamps(); }); }
/** * Create Schema * * @return AdapterInterface */ public function createSchema() { /* @var \Illuminate\Database\Schema\Blueprint $table */ $this->adapter->schema()->create($this->tableName, function ($table) { $table->string('version'); }); }
/** * Returns true if the specified table exists in the database. * * @param $table * * @return bool */ public function TableExists($table) { if ($this->capsule->schema()->hasTable($table)) { return true; } return false; }
public static function createConn() { $capsule = new DB(); $capsule->addConnection(parse_ini_file("./config/config.ini")); $capsule->setAsGlobal(); $capsule->bootEloquent(); }
protected function setConnection(array $connection) { $this->capsule = new Capsule(); $this->capsule->addConnection($connection); $this->capsule->setAsGlobal(); $this->capsule->bootEloquent(); }
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(); }
public function __construct($config = []) { $capsule = new Capsule; $capsule->addConnection($config); $capsule->bootEloquent(); return $capsule; }
public function __construct() { $setting = parse_ini_file(BASEDIR . "setting.ini.php"); $capsule = new Capsule(); $capsule->addConnection(array('host' => $setting['host'], 'database' => $setting['database'], 'username' => $setting['username'], 'password' => $setting['password'], 'driver' => 'mysql', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '')); $capsule->setAsGlobal(); $capsule->bootEloquent(); }
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(); }
/** * Registers Eloquent. * * @return void */ protected function registerEloquent() { global $wpdb; $capsule = new Capsule($this->app); $capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => DB_CHARSET, 'collation' => DB_COLLATE ?: $wpdb->collate, 'prefix' => $wpdb->prefix]); $capsule->setAsGlobal(); $capsule->bootEloquent(); }