本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application::runningInConsole方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::runningInConsole方法的具体用法?PHP Application::runningInConsole怎么用?PHP Application::runningInConsole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Foundation\Application
的用法示例。
在下文中一共展示了Application::runningInConsole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupSeeds
/**
* Setup the seeds.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupSeeds(Application $app)
{
$source = realpath(__DIR__ . '/../database/seeds/');
if ($app instanceof LaravelApplication && $app->runningInConsole()) {
$this->publishes([$source => database_path('seeds')], 'seeds');
}
}
示例2: isRunningInConsole
/**
* Determine if the app is running in the console.
*
* To allow testing this will return false the environment is testing.
*
* @return bool
*/
public function isRunningInConsole()
{
if ($this->app->environment('testing')) {
return false;
}
return $this->app->runningInConsole();
}
示例3: load
/**
* Register the application service providers.
*
* @param array $providers
* @return void
*/
public function load(array $providers)
{
$manifest = $this->loadManifest();
// First we will load the service manifest, which contains information on all
// service providers registered with the application and which services it
// provides. This is used to know which services are "deferred" loaders.
if ($this->shouldRecompile($manifest, $providers)) {
$manifest = $this->compileManifest($providers);
}
// If the application is running in the console, we will not lazy load any of
// the service providers. This is mainly because it's not as necessary for
// performance and also so any provided Artisan commands get registered.
if ($this->app->runningInConsole()) {
$manifest['eager'] = $manifest['providers'];
}
// Next, we will register events to load the providers for each of the events
// that it has requested. This allows the service provider to defer itself
// while still getting automatically loaded when a certain event occurs.
foreach ($manifest['when'] as $provider => $events) {
$this->registerLoadEvents($provider, $events);
}
// We will go ahead and register all of the eagerly loaded providers with the
// application so their services can be registered with the application as
// a provided service. Then we will set the deferred service list on it.
foreach ($manifest['eager'] as $provider) {
$this->app->register($this->createProvider($provider));
}
$this->app->setDeferredServices($manifest['deferred']);
}
示例4: handleException
/**
* Handle an uncaught exception from the application.
*
* Note: Most exceptions can be handled via the try / catch block in
* the HTTP and Console kernels. But, fatal error exceptions must
* be handled differently since they are not normal exceptions.
*
* @param \Exception $e
* @return void
*/
public function handleException($e)
{
$this->getExceptionHandler()->report($e);
if ($this->app->runningInConsole()) {
$this->renderForConsole($e);
} else {
$this->renderHttpResponse($e);
}
}
示例5: handleException
/**
* Handle an uncaught exception from the application.
*
* Note: Most exceptions can be handled via the try / catch block in
* the HTTP and Console kernels. But, fatal error exceptions must
* be handled differently since they are not normal exceptions.
*
* @param \Throwable $e
* @return void
*/
public function handleException($e)
{
if (!$e instanceof Exception) {
$e = new FatalThrowableError($e);
}
$this->getExceptionHandler()->report($e);
if ($this->app->runningInConsole()) {
$this->renderForConsole($e);
} else {
$this->renderHttpResponse($e);
}
}
示例6: boot
public function boot(Application $app)
{
$source = realpath(__DIR__ . '/migrations/');
if ($app->runningInConsole()) {
$this->publishes([$source => database_path('migrations')], 'migrations');
}
}
示例7: setupMigrations
/**
* Setup the migrations.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupMigrations(Application $app)
{
$source = realpath(__DIR__ . '/../database/migrations/');
if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
$this->publishes([$source => database_path('migrations')], 'migrations');
}
}
示例8: initMigration
/**
* Copy migration to resources
*
* @param Application $app
*/
private function initMigration(Application $app)
{
if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
$migrationPath = realpath(__DIR__ . '/../database/migrations');
$this->publishes([$migrationPath => database_path('migrations')]);
}
}
示例9: 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');
}
示例10: initCMS
/**
* Copy migration to root project
*
* @param Application $app
*/
private function initCMS(Application $app)
{
if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
$migrationPath = realpath(__DIR__ . '/migration');
(new Filesystem())->makeDirectory(app_path('Models'), 0755, false, true);
$this->publishes([$migrationPath => database_path('migrations'), __DIR__ . "/module" => app_path('Http/Modules'), __DIR__ . "/resource" => resource_path(), __DIR__ . "/gulp" => base_path(), __DIR__ . "/configs" => config_path('cms')]);
}
}
示例11: setupConfig
/**
* Setup the config.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupConfig(Application $app)
{
$source = realpath(__DIR___ . '/../config/gitlib.php');
if ($app instanceof LaravelApplication && $app->runningInConsole()) {
$this->publishes([$source => config_path('gitlib.php')]);
} elseif ($app instanceof LumanApplication) {
$app->configure('gitlib');
}
$this->mergeConfigFrom($source, 'gitlib');
}
示例12: setupConfig
/**
* Setup the config.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupConfig(Application $app)
{
$source = realpath(__DIR__ . '/../config/pusher.php');
if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
$this->publishes([$source => config_path('pusher.php')]);
} elseif (class_exists('Laravel\\Lumen\\Application', false)) {
$app->configure('pusher');
}
$this->mergeConfigFrom($source, 'pusher');
}
示例13: setupConfig
/**
* Setup the config.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupConfig(Application $app)
{
$source = __DIR__ . '/config/telegram.php';
if ($app instanceof LaravelApplication && $app->runningInConsole()) {
$this->publishes([$source => config_path('telegram.php')]);
} elseif ($app instanceof LumenApplication) {
$app->configure('telegram');
}
$this->mergeConfigFrom($source, 'telegram');
}
示例14: error
protected function error(\Exception $e)
{
global $argv;
if ($this->app->runningInConsole() && in_array('package:publish', $argv)) {
$command = $this->container->command();
if ($command) {
$command->error($e->getMessage());
}
return;
}
throw $e;
}
示例15: handle
/**
* Handle the command.
*
* @param Application $application
*/
public function handle(Application $application, Laravel $laravel)
{
$app = env('APPLICATION_REFERENCE', 'default');
if ($laravel->runningInConsole()) {
$app = (new ArgvInput())->getParameterOption('--app', $app);
$laravel->bind('path.public', function () use($laravel) {
if ($path = env('PUBLIC_PATH')) {
return base_path($path);
}
// Check default path.
if (file_exists($path = base_path('public/index.php'))) {
return dirname($path);
}
// Check common alternative.
if (file_exists($path = base_path('public_html/index.php'))) {
return dirname($path);
}
return base_path('public');
});
}
/**
* Set the reference to our default first.
* When in a dev environment and working
* with Artisan this the same as locating.
*/
$application->setReference($app);
/**
* If the application is installed
* then locate the application and
* initialize.
*/
if ($application->isInstalled()) {
if (env('DB_DRIVER')) {
$application->locate();
$application->setup();
}
return;
}
/**
* If we're not installed just
* assume default for now.
*/
$application->setReference('default');
}