本文整理汇总了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());
}
}
示例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');
}
示例3: shouldCatchErrors
protected function shouldCatchErrors($default = true, $production_default = false)
{
if ($this->app->environment() == 'production') {
return $production_default;
} else {
return $default;
}
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
*/
}
示例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;
}
示例9: environment
/**
* Get or check the current application environment.
*
* @param mixed
* @return string
* @static
*/
public static function environment()
{
return \Illuminate\Foundation\Application::environment();
}
示例10: isTrackableEnvironment
private function isTrackableEnvironment()
{
return !in_array($this->laravel->environment(), $this->config->get('do_not_track_environments'));
}
示例11: getConfirmationText
/**
* The confirmation text to show
*
* @return string
*/
public function getConfirmationText()
{
return 'Application in ' . ucfirst($this->app->environment());
}
示例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);
}
示例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();
}