本文整理汇总了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
示例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;
}