當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::environment方法代碼示例

本文整理匯總了PHP中Illuminate\Foundation\Application::environment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::environment方法的具體用法?PHP Application::environment怎麽用?PHP Application::environment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Foundation\Application的用法示例。


在下文中一共展示了Application::environment方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: send

 /**
  * {@inheritdoc}
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $mailmanMessage = new MailmanMimeMessage($message);
     $this->beforeSendPerformed($message);
     // Deny email delivery if environment is not allowed in the config
     if (!in_array($this->app->environment(), config('mailman.delivery.environments'))) {
         $mailmanMessage->deny();
         $recipients = array_keys($mailmanMessage->getTo());
         $allowedRecipients = config('mailman.delivery.recipients');
         $recipientsDiff = array_diff($recipients, $allowedRecipients);
         // If all recipients are allowed to receive emails
         // from denied environments - allow email delivery.
         if (count($recipientsDiff) === 0) {
             $mailmanMessage->allow();
         }
     } else {
         $mailmanMessage->allow();
     }
     if (config('mailman.log.enabled')) {
         $logger = app('mailman.logger');
         $logger->log($mailmanMessage);
     }
     if ($mailmanMessage->allowed()) {
         /** @var Swift_Transport $transport */
         $transport = $this->app['swift.transport']->driver(config('mailman.delivery.driver'));
         with(new Swift_Mailer($transport))->send($mailmanMessage->getSwiftMessage());
     }
 }
開發者ID:qodeboy,項目名稱:laravel-mailman,代碼行數:31,代碼來源:MailmanTransport.php

示例2: path

 public function path($extension)
 {
     $type = $this->config->get('assets.types.' . $extension);
     if ($this->app->environment() == 'local') {
         return $this->asset($type['origin_dir']);
     }
     return $this->asset($type['dist_dir']) . '/' . $this->cache->get('laravel-asset-versioning.version');
 }
開發者ID:escapework,項目名稱:laravel-asset-versioning,代碼行數:8,代碼來源:Asset.php

示例3: shouldCatchErrors

 protected function shouldCatchErrors($default = true, $production_default = false)
 {
     if ($this->app->environment() == 'production') {
         return $production_default;
     } else {
         return $default;
     }
 }
開發者ID:winglian,項目名稱:middleware-adapter,代碼行數:8,代碼來源:WhoopsMiddleware.php

示例4: __construct

 /**
  * Constructor.
  */
 public function __construct(RollbarNotifier $rollbar, Application $app, $level = 'debug')
 {
     $this->rollbar = $rollbar;
     $this->app = $app;
     $this->level = $this->parseLevel($level ?: 'debug');
     // Set Laravel information
     $this->rollbar->environment = $this->app['config']->get('services.rollbar.environment', $this->app->environment());
     $this->rollbar->root = base_path();
 }
開發者ID:ssx,項目名稱:laravel-rollbar,代碼行數:12,代碼來源:RollbarLogHandler.php

示例5: getSiteName

 protected function getSiteName()
 {
     $title = $this->config->get('c::site.html-name') ?: ($this->config->get('c::site.name') ?: $this->config->get('app.url'));
     $env = $this->app->environment();
     if ($env !== 'production') {
         $title .= ' <strong>' . strtoupper($env) . '</strong>';
     }
     return $title;
 }
開發者ID:anlutro,項目名稱:l4-core,代碼行數:9,代碼來源:MenuViewCreator.php

示例6: addContext

 /**
  * Add Laravel specific information to the context.
  *
  * @param array $context
  */
 protected function addContext(array $context = [])
 {
     // Add session data.
     if ($session = $this->app->session->all()) {
         if (empty($context['user']) or !is_array($context['user'])) {
             $context['user'] = [];
         }
         if (isset($context['user']['data'])) {
             $context['user']['data'] = array_merge($session, $context['user']['data']);
         } else {
             $context['user']['data'] = $session;
         }
         // User session id as user id if not set.
         if (!isset($context['user']['id'])) {
             $context['user']['id'] = $this->app->session->getId();
         }
     }
     // Automatic tags
     $tags = ['environment' => $this->app->environment(), 'server' => $this->app->request->server('HTTP_HOST')];
     // Add tags to context.
     if (isset($context['tags'])) {
         $context['tags'] = array_merge($tags, $context['tags']);
     } else {
         $context['tags'] = $tags;
     }
     // Automatic extra data.
     $extra = ['ip' => $this->app->request->getClientIp()];
     // Everything that is not 'user', 'tags' or 'level' is automatically considered
     // as additonal 'extra' context data.
     $extra = array_merge($extra, array_except($context, ['user', 'tags', 'level', 'extra']));
     // Add extra to context.
     if (isset($context['extra'])) {
         $context['extra'] = array_merge($extra, $context['extra']);
     } else {
         $context['extra'] = $extra;
     }
     // Clean out other values from context.
     $context = array_only($context, ['user', 'tags', 'level', 'extra']);
     return $context;
 }
開發者ID:bmaynard,項目名稱:laravel-raven,代碼行數:45,代碼來源:RavenLogHandler.php

示例7: __construct

 /**
  * @param Filesystem  $filesystem
  * @param Application $app
  */
 public function __construct(Filesystem $filesystem, Application $app)
 {
     $this->app = $app;
     $this->env = $this->app->environment();
     $this->file = $filesystem;
     $this->configFile = $this->app['path'] . '/config/app.php';
     /*
     Adding environment-specific packages has some nuances
     See:
     https://github.com/laravel/framework/issues/1603
     https://github.com/barryvdh/laravel-debugbar/issues/86
     https://github.com/laravel/framework/issues/3327
     So at the moment this is at stage of TODO
     if ($this->env === 'production') {
         $this->configFile = $this->app['path'] . '/config/app.php';
     }
     else {
         $this->configFile = $this->app['path'] . '/config/' . $this->env . '/app.php';
         if (!$this->file->exists($this->configFile)) {
             $this->file->copy(__DIR__ . '/app.config.stub', $this->configFile);
         }
     }
     */
 }
開發者ID:acacha,項目名稱:laravel-utils,代碼行數:28,代碼來源:ConfigUpdater.php

示例8: addContext

 /**
  * Add Laravel specific information to the context.
  *
  * @param array $context
  */
 protected function addContext(array $context = [])
 {
     // Add session data.
     if ($session = $this->app->session->all()) {
         if (empty($context['user']) or !is_array($context['user'])) {
             $context['user'] = [];
         }
         if (isset($context['user']['data'])) {
             $context['user']['data'] = array_merge($session, $context['user']['data']);
         } else {
             $context['user']['data'] = $session;
         }
         // User session id as user id if not set.
         if (!isset($context['user']['id'])) {
             $context['user']['id'] = $this->app->session->getId();
         }
     }
     try {
         $gitBranch = implode('/', array_slice(explode('/', file_get_contents(app_path() . '/../.git/HEAD')), 2));
     } catch (Exception $e) {
         $gitBranch = 'undefined';
     }
     // Automatic tags
     $tags = ['branch' => $gitBranch, 'environment' => $this->app->environment(), 'server' => $this->app->request->server('HTTP_HOST')];
     // Add tags to context.
     if (isset($context['tags'])) {
         $context['tags'] = array_merge($tags, $context['tags']);
     } else {
         $context['tags'] = $tags;
     }
     // Automatic extra data.
     $extra = ['ip' => $this->app->request->getClientIp()];
     // Everything that is not 'user', 'tags' or 'level' is automatically considered
     // as additonal 'extra' context data.
     $extra = array_merge($extra, array_except($context, ['user', 'tags', 'level', 'extra']));
     // Add extra to context.
     if (isset($context['extra'])) {
         $context['extra'] = array_merge($extra, $context['extra']);
     } else {
         $context['extra'] = $extra;
     }
     // Clean out other values from context.
     $context = array_only($context, ['user', 'tags', 'level', 'extra']);
     return $context;
 }
開發者ID:OdenFrey,項目名稱:laravel-raven,代碼行數:50,代碼來源:RavenLogHandler.php

示例9: environment

 /**
  * Get or check the current application environment.
  *
  * @param mixed
  * @return string 
  * @static 
  */
 public static function environment()
 {
     return \Illuminate\Foundation\Application::environment();
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:11,代碼來源:_ide_helper.php

示例10: isTrackableEnvironment

 private function isTrackableEnvironment()
 {
     return !in_array($this->laravel->environment(), $this->config->get('do_not_track_environments'));
 }
開發者ID:Riesjart,項目名稱:tracker,代碼行數:4,代碼來源:Tracker.php

示例11: getConfirmationText

 /**
  * The confirmation text to show
  *
  * @return string
  */
 public function getConfirmationText()
 {
     return 'Application in ' . ucfirst($this->app->environment());
 }
開發者ID:indatus,項目名稱:guardian,代碼行數:9,代碼來源:ConfirmationService.php

示例12:

 function it_should_not_confirm_when_not_in_configured_enivronment(Application $app, Repository $config)
 {
     $config->get('guardian::environments')->willReturn(['local']);
     $app->environment('local')->willReturn(false);
     $this->needsConfirmation()->shouldBe(false);
 }
開發者ID:indatus,項目名稱:guardian,代碼行數:6,代碼來源:ConfirmationServiceSpec.php

示例13: __construct

 /**
  *  Create a new SaveUrlMiddleware instance
  *
  *  @param  Store   $store
  *  @param  Config  $config
  *  @return void
  */
 public function __construct(Application $app)
 {
     $this->store = $app['session.store'];
     $this->sessionKey = $app['config']->get('save-url.session-key');
     $this->isRunningInConsole = !$app->environment('testing') && $app->runningInConsole();
 }
開發者ID:Waavi,項目名稱:save-url,代碼行數:13,代碼來源:SaveUrlMiddleware.php


注:本文中的Illuminate\Foundation\Application::environment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。