当前位置: 首页>>代码示例>>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;未经允许,请勿转载。