當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentry::setupDatabaseResolver方法代碼示例

本文整理匯總了PHP中Sentry::setupDatabaseResolver方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentry::setupDatabaseResolver方法的具體用法?PHP Sentry::setupDatabaseResolver怎麽用?PHP Sentry::setupDatabaseResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentry的用法示例。


在下文中一共展示了Sentry::setupDatabaseResolver方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: class_alias

    $_SESSION['slim.flash'] = '';
}
/*****************************************************************/
// LOAD THE FRAMEWORK
/*****************************************************************/
require VENDORS_PATH . '/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(array('mode' => 'development'));
include_once VENDORS_PATH . '/autoload.php';
include_once CONFIGS_PATH . '/database.php';
include_once CONFIGS_PATH . '/application.php';
// CREATE ALIAS FOR FACADE
class_alias('Cartalyst\\Sentry\\Facades\\Native\\Sentry', 'Sentry');
// Setup our database
$dsn = DRIVER . ":dbname=" . DBNAME . ";host=" . DBHOST;
Sentry::setupDatabaseResolver(new PDO($dsn, DBUSER, DBPASS));
// ELOQUENT ORM
$settings = array('driver' => DRIVER, 'host' => DBHOST, 'database' => DBNAME, 'username' => DBUSER, 'password' => DBPASS, 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '');
// OBJECT MAPPER
$container = new \Illuminate\Container\Container();
$connFactory = new \Illuminate\Database\Connectors\ConnectionFactory($container);
$conn = $connFactory->make($settings);
$resolver = new \Illuminate\Database\ConnectionResolver();
$resolver->addConnection('default', $conn);
$resolver->setDefaultConnection('default');
\Illuminate\Database\Eloquent\Model::setConnectionResolver($resolver);
// AUTOLOADERS
include_once dirname(__FILE__) . '/autoloader.php';
AutoLoader::registerDirectory(dirname(__FILE__) . '/models');
AutoLoader::registerDirectory(dirname(__FILE__) . '/classes');
// ROUTE FILES
開發者ID:kxopa,項目名稱:PHPLotterySystem,代碼行數:31,代碼來源:bootstrap.php

示例2: function

/**
 * Boot up Eloquent
 */
use Illuminate\Database\Capsule\Manager as Capsule;
$app->hook('slim.before', function () use($app, $config) {
    try {
        $app->container->singleton('db', function () {
            return new Capsule();
        });
        $app->db->addConnection($config['database']);
        $app->db->setAsGlobal();
        $app->db->bootEloquent();
        /**
         * Setting up Sentry
         */
        Sentry::setupDatabaseResolver($app->db->connection()->getPdo());
    } catch (PDOException $e) {
        if (file_exists(PUBLIC_PATH . 'install.php') && !defined('INSTALL')) {
            /**
             * In case app can not connect to the database and install script was found, redirect to install script
             * we assume that application is not configured yet
             */
            $publicPath = dirname($_SERVER['SCRIPT_NAME']) . '/';
            $installPath = Request::getUrl() . $publicPath . 'install.php';
            Response::redirect($installPath);
        } else {
            /**
             * If install script can not be found, re throw the exception to be handled by Slim
             */
            throw $e;
        }
開發者ID:acmadi,項目名稱:SlimStarter,代碼行數:31,代碼來源:app.php


注:本文中的Sentry::setupDatabaseResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。