本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::instance方法的具体用法?PHP Application::instance怎么用?PHP Application::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Foundation\Application
的用法示例。
在下文中一共展示了Application::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendRequestThroughRouter
/**
* Send through our custom router
*
* @param $request
*
* @return Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
return (new Pipeline($this->app))->send($request)->through($this->middleware)->then(function ($request) {
return $this->router->dispatch($this->alexaRequest);
});
}
示例2: createFreshMockInstance
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createFreshMockInstance($name)
{
static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
if (isset(static::$app)) {
static::$app->instance($name, $mock);
}
return $mock;
}
示例3: createFreshMockInstance
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createFreshMockInstance($name)
{
static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
$mock->shouldAllowMockingProtectedMethods();
if (isset(static::$app)) {
static::$app->instance($name, $mock);
}
return $mock;
}
示例4: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
public function bootstrap(Application $app)
{
$items = [];
$app->instance('config', $config = new Repository($items));
$this->loadConfigurationFiles($app, $config);
mb_internal_encoding('UTF-8');
}
示例5: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
/** @var \Illuminate\Foundation\Application $app*/
$env = $app->environment();
$filesystem = $this->files = new Filesystem();
$loader = new FileLoader($filesystem, $app['path.config']);
$config = new Repository($loader, $filesystem, $env);
$loader->setRepository($config);
$app->instance('config', $config);
$configuredLoader = $app['config']->get('laradic_config.loader');
if (isset($configuredLoader) && $configuredLoader !== 'file') {
if ($configuredLoader === 'db') {
$loader = new DatabaseLoader($filesystem, $app['path.config']);
$config->setLoader($loader);
$app->booted(function () use($app, $loader, $config) {
$loader->setDatabase($app['db']->connection());
$loader->setDatabaseTable($app['config']->get('laradic_config.loaders.db.table'));
});
$loader->setRepository($config);
}
}
if (file_exists($cached = $app->getCachedConfigPath()) && !$app->runningInConsole()) {
$items = (require $cached);
$loadedFromCache = true;
}
if (!isset($loadedFromCache)) {
# $this->loadConfigurationFiles($app, $config);
}
date_default_timezone_set($config['app.timezone']);
mb_internal_encoding('UTF-8');
}
示例6: dispatchToRouter
/**
* Get the route dispatcher callback.
*
* @return \Closure
*/
protected function dispatchToRouter()
{
return function ($request) {
$this->app->instance('request', $request);
return $this->router->dispatch($request);
};
}
示例7: registerLogger
/**
* Register the logger instance in the container.
*
* @param \Illuminate\Foundation\Application|Application $app
* @return \Illuminate\Log\Writer
*/
protected function registerLogger(Application $app)
{
$logger = new Logger($app->environment());
//< do not move this! it might produce "Class declarations may not be nested" error
$log = new Writer($logger, $app['events']);
$app->instance('log', $log);
return $log;
}
示例8: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application
*
* @return void
*/
public function bootstrap(Application $application)
{
$loader = new FileLoader(new Filesystem(), $application['path'] . DIRECTORY_SEPARATOR . 'configurations');
$application->instance('config', $configuration = new Repository($loader, $application->environment()));
if (!isset($loadedFromCache)) {
$this->loadConfigurationFiles($application, $configuration);
}
mb_internal_encoding('UTF-8');
}
示例9: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$fileLoader = new FileLoader(new Filesystem(), base_path() . '/config');
$app->instance('config', $config = new Repository($fileLoader, $app['env']));
date_default_timezone_set($config['app.timezone']);
mb_internal_encoding('UTF-8');
// Fix for XDebug aborting threads > 100 nested
ini_set('xdebug.max_nesting_level', 300);
}
示例10: storeConfiguration
protected function storeConfiguration()
{
$dbConfig = $this->dbConfig;
$config = ['debug' => false, 'database' => ['driver' => $dbConfig['driver'], 'host' => $dbConfig['host'], 'database' => $dbConfig['database'], 'username' => $dbConfig['username'], 'password' => $dbConfig['password'], 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => $dbConfig['prefix'], 'strict' => false], 'url' => $this->baseUrl, 'paths' => ['api' => 'api', 'admin' => 'admin']];
$this->info('Testing config');
$this->application->instance('flarum.config', $config);
/* @var $db \Illuminate\Database\ConnectionInterface */
$db = $this->application->make('flarum.db');
$version = $db->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
if (version_compare($version, '5.5.0', '<')) {
throw new Exception('MySQL version too low. You need at least MySQL 5.5.');
}
$this->info('Writing config');
file_put_contents($this->getConfigFile(), '<?php return ' . var_export($config, true) . ';');
}
示例11: bootstrap
/**
* @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application
*
* @return void
*/
public function bootstrap(Application $application)
{
$items = [];
if (file_exists($cached = $application->getCachedConfigPath())) {
$items = (require $cached);
$loadedFromCache = true;
}
$application->instance('config', $config = new Repository($items));
if (!isset($loadedFromCache)) {
$this->loadConfigurationFiles($application, $config);
}
$application->detectEnvironment(function () use($config) {
return $config->get('app.env', 'production');
});
mb_internal_encoding('UTF-8');
}
示例12: __construct
/**
* Constructor
*/
public function __construct(\Illuminate\Contracts\Foundation\Application $app)
{
$this->app = $app;
$app->instance('application', $this);
if (function_exists('ini_set') && extension_loaded('xdebug')) {
ini_set('xdebug.show_exception_trace', false);
ini_set('xdebug.scream', false);
}
// Config TimeZone
if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
date_default_timezone_set(@date_default_timezone_get());
}
ErrorHandler::register();
$this->bootstrap();
parent::__construct($this->title, $this->version);
}
示例13: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$logger = new Writer(new Monolog($app->environment()), $app['events']);
// Daily files are better for production stuff
$logger->useDailyFiles(storage_path('/logs/laravel.log'));
$app->instance('log', $logger);
// Next we will bind the a Closure to resolve the PSR logger implementation
// as this will grant us the ability to be interoperable with many other
// libraries which are able to utilize the PSR standardized interface.
$app->bind('Psr\\Log\\LoggerInterface', function ($app) {
return $app['log']->getMonolog();
});
$app->bind('Illuminate\\Contracts\\Logging\\Log', function ($app) {
return $app['log'];
});
}
示例14: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = storage_path('framework/config.php'))) {
$items = (require $cached);
$loadedFromCache = true;
}
$app->instance('config', $config = new Repository($items));
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
if (!isset($loadedFromCache)) {
$this->loadConfigurationFiles($config);
}
date_default_timezone_set($config['app.timezone']);
}
示例15: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
/*if (file_exists($cached = $app->getCachedConfigPath()))
{
$items = require $cached;
$loadedFromCache = true;
}*/
$app->instance('config', $config = new IlluminatoRepository($items));
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
if (!isset($loadedFromCache)) {
$this->loadConfigurationFiles($app->configPath(), $config);
}
date_default_timezone_set($config['app.timezone']);
mb_internal_encoding('UTF-8');
}