当前位置: 首页>>代码示例>>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;未经允许,请勿转载。