本文整理汇总了PHP中Phalcon\DI\FactoryDefault::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP FactoryDefault::setDefault方法的具体用法?PHP FactoryDefault::setDefault怎么用?PHP FactoryDefault::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\DI\FactoryDefault
的用法示例。
在下文中一共展示了FactoryDefault::setDefault方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
static::$di = new Di();
Di::setDefault(static::$di);
putenv('APP_ENV');
unset($_ENV['APP_ENV'], $_SERVER['APP_ENV']);
}
示例2: setUp
public function setUp()
{
static::$di = new Di();
Di::setDefault(static::$di);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
示例3: function
}, true);
/**
* Router
*/
$di->set('router', function () {
$router = new PhRouter(false);
return $router;
}, true);
/**
* Dispatcher
*/
$di->set('dispatcher', function () use($di) {
$dispatcher = new PhDispatcher();
return $dispatcher;
});
/**
* Db
*/
$di->set('db', function () use($di) {
$config = $di['config'];
$params = ["host" => $config->app_db_test->host, "username" => $config->app_db_test->username, "password" => $config->app_db_test->password, "dbname" => $config->app_db_test->dbname, "charset" => $config->app_db_test->charset];
$adapter = $config->app_db_test->adapter;
$conn = new $adapter();
// Set everything to UTF8
$conn->execute('SET NAMES UTF8', []);
return $conn;
});
$application = new PhApplication();
$application->setDI($di);
PhDI::setDefault($di);
return $application;
示例4: function
return $url;
});
/**
* Router
*/
$di->setShared('router', function () {
return new Router(false);
});
/**
* Dispatcher
*/
$di->set('dispatcher', function () use($di) {
return new Dispatcher();
});
/**
* Initialize the Database connection
*/
$di->set('db', function () use($di) {
$config = $di['config'];
$config = $config->get('database')->toArray();
$adapter = '\\Phalcon\\Db\\Adapter\\Pdo\\' . $config['adapter'];
unset($config['adapter']);
/** @var \Phalcon\Db\AdapterInterface $connection */
$connection = new $adapter($config);
$connection->execute('SET NAMES UTF8', []);
return $connection;
});
$application = new Application();
$application->setDI($di);
FactoryDefault::setDefault($di);
return $application;