当前位置: 首页>>代码示例>>PHP>>正文


PHP Capsule\Manager类代码示例

本文整理汇总了PHP中Illuminate\Database\Capsule\Manager的典型用法代码示例。如果您正苦于以下问题:PHP Manager类的具体用法?PHP Manager怎么用?PHP Manager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 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;
     });
 }
开发者ID:gigablah,项目名称:silex-db,代码行数:28,代码来源:DatabaseServiceProvider.php

示例2: onBootstrap

 /**
  * @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();
     });
 }
开发者ID:middleout,项目名称:doplio-zf2,代码行数:37,代码来源:Module.php

示例3: initialize

 /**
  * Initializes the Eloquent ORM.
  */
 public function initialize()
 {
     $this->capsule->bootEloquent();
     if ('default' !== $this->defaultConnection) {
         $this->capsule->getDatabaseManager()->setDefaultConnection($this->defaultConnection);
     }
 }
开发者ID:wouterj,项目名称:eloquent-bundle,代码行数:10,代码来源:EloquentInitializer.php

示例4: register

 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;
     });
 }
开发者ID:shomimn,项目名称:builder,代码行数:28,代码来源:DatabaseServiceProvider.php

示例5: _makeEloquent

 /**
  * 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;
 }
开发者ID:leandrocanabarro,项目名称:lassi,代码行数:38,代码来源:Database.php

示例6: register

 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();
     });
 }
开发者ID:singularity321,项目名称:Arty,代码行数:25,代码来源:DatabaseServiceProvider.php

示例7: configureDatabase

 protected function configureDatabase()
 {
     $db = new DB();
     $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']);
     $db->bootEloquent();
     $db->setAsGlobal();
 }
开发者ID:adamwathan,项目名称:faktory,代码行数:7,代码来源:FunctionalTestCase.php

示例8: setUpDatabase

 /**
  * @return DB
  */
 public function setUpDatabase()
 {
     $db = new DB();
     $db->addConnection(['driver' => 'sqlite', 'database' => ':memory:']);
     $db->setAsGlobal();
     $db->bootEloquent();
 }
开发者ID:sabahtalateh,项目名称:laracast,代码行数:10,代码来源:CustomerRepositoryTest.php

示例9: configureDatabaseConnection

 /**
  * 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();
 }
开发者ID:thirteen,项目名称:testbench,代码行数:13,代码来源:DatabaseConnection.php

示例10: init

 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();
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:7,代码来源:Migration.php

示例11: __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();
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:7,代码来源:user.php

示例12: start

 /**
  * 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();
 }
开发者ID:justincdotme,项目名称:bookme,代码行数:11,代码来源:Database.php

示例13: register

 /**
  * {@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());
     });
 }
开发者ID:intfrr,项目名称:opencfp,代码行数:35,代码来源:ApplicationServiceProvider.php

示例14: boot

 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();
 }
开发者ID:paulboco,项目名称:vorhysun,代码行数:7,代码来源:EloquentCapsule.php

示例15: setUpDatabases

 private function setUpDatabases()
 {
     $database = new DB();
     $database->addConnection(['driver' => 'sqlite', 'database' => ':memory:']);
     $database->bootEloquent();
     $database->setAsGlobal();
 }
开发者ID:steveazz,项目名称:rudolly,代码行数:7,代码来源:TestCase.php


注:本文中的Illuminate\Database\Capsule\Manager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。