本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application::environment方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::environment方法的具体用法?PHP Application::environment怎么用?PHP Application::environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Foundation\Application
的用法示例。
在下文中一共展示了Application::environment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModeByEnv
/**
* Get checking mode by laravel environment.
*
* @param string|null $env
*
* @return string
*/
protected function getModeByEnv($env = null)
{
if (is_null($env)) {
$env = $this->app->environment();
}
return in_array($env, $this->productionEnvironments) ? 'Production' : 'Dev';
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance() && $this->app->environment() != 'testing') {
throw new HttpException(503, 'Server is currently undergoing maintenance. We should be ' . 'back up shortly.');
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && $this->app->environment() === 'production') {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例4: 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();
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->environment() === 'production') {
// for Proxies
Request::setTrustedProxies([$request->getClientIp()]);
if (!$request->isSecure()) {
return redirect()->secure($request->getRequestUri());
}
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ('testing' === $this->app->environment() && $request->has('_token')) {
$input = $request->all();
$input['_token'] = $request->session()->token();
// we need to update _token value to make sure we get the POST / PUT tests passed.
Log::debug('Input token replaced (' . $input['_token'] . ').');
$request->replace($input);
}
return $next($request);
}
示例7: 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');
}
示例8: 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;
}
示例9: 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');
}
示例10: getConfigurationFiles
protected function getConfigurationFiles(Application $app)
{
$configPath = str_finish($app->configPath(), '/');
$files = $this->getConfigurationFilesInPath($configPath);
foreach (explode('.', $app->environment()) as $env) {
$configPath .= $env . '/';
$files = array_merge_recursive($files, $this->getConfigurationFilesInPath($configPath));
}
return $files;
}
示例11: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$this->app = $app;
error_reporting(-1);
set_error_handler([$this, 'handleError']);
set_exception_handler([$this, 'handleException']);
register_shutdown_function([$this, 'handleShutdown']);
if (!$app->environment('testing')) {
ini_set('display_errors', 'Off');
}
}
示例12: loadData
/**
* Overwrite the original config value based
* on environment name.
*
* @param array $configs
* @param Closure|null $closure
*
* @return void
*/
protected function loadData($configs, Closure $closure = null)
{
if (is_null($configs)) {
return false;
}
foreach ($configs as $env => $config) {
$env = $this->explodeEnvironment($env);
if (is_array($env)) {
foreach ($env as $_env) {
if ($this->app->environment($_env)) {
$closure($config);
}
}
} else {
if ($this->app->environment($env)) {
$closure($config);
}
}
}
}
示例13: index
/**
* index.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Recca0120\Terminal\Kernel $kernel
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Response\Factory $responseFactory
* @param \Illuminate\Contracts\Routing\UrlGenerator $urlGenerator
* @param string $view
*
* @return mixed
*/
public function index(Application $app, Kernel $kernel, Request $request, ResponseFactory $responseFactory, UrlGenerator $urlGenerator, $view = 'index')
{
$kernel->call('--ansi');
$csrfToken = null;
if ($request->hasSession() === true) {
$csrfToken = $request->session()->token();
}
$options = json_encode(['csrfToken' => $csrfToken, 'username' => 'LARAVEL', 'hostname' => php_uname('n'), 'os' => PHP_OS, 'basePath' => $app->basePath(), 'environment' => $app->environment(), 'version' => $app->version(), 'endpoint' => $urlGenerator->action('\\' . static::class . '@endpoint'), 'helpInfo' => $kernel->output(), 'interpreters' => ['mysql' => 'mysql', 'artisan tinker' => 'tinker', 'tinker' => 'tinker'], 'confirmToProceed' => ['artisan' => ['migrate', 'migrate:install', 'migrate:refresh', 'migrate:reset', 'migrate:rollback', 'db:seed']]]);
$id = $view === 'panel' ? Str::random(30) : null;
return $responseFactory->view('terminal::' . $view, compact('options', 'resources', 'id'));
}
示例14: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application
*
* @return void
*/
public function bootstrap(Application $application)
{
$this->app = $application;
error_reporting(-1);
set_error_handler([$this, 'handleError']);
set_exception_handler([$this, 'handleException']);
register_shutdown_function([$this, 'handleShutdown']);
if (!$application->environment('testing')) {
ini_set('display_errors', 'Off');
}
if ($application->make('config')->get('app.debug')) {
ini_set('display_errors', true);
}
}
示例15: 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'];
});
}