Files
panel-pelican-dev/app/Console/Commands/Environment/AppSettingsCommand.php

51 lines
1.5 KiB
PHP
Raw Normal View History

2017-09-22 21:19:57 -05:00
<?php
2024-03-12 22:39:16 -04:00
namespace App\Console\Commands\Environment;
2017-09-22 21:19:57 -05:00
use App\Traits\EnvironmentWriterTrait;
2017-09-22 21:19:57 -05:00
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
2017-09-22 21:19:57 -05:00
class AppSettingsCommand extends Command
{
use EnvironmentWriterTrait;
2024-05-15 15:14:17 -04:00
2017-09-22 21:19:57 -05:00
protected $description = 'Configure basic environment settings for the Panel.';
protected $signature = 'p:environment:setup
{--url= : The URL that this Panel is running on.}';
2017-09-22 21:19:57 -05:00
protected array $variables = [];
2017-09-22 21:19:57 -05:00
public function handle(): void
2017-09-22 21:19:57 -05:00
{
2024-05-07 21:52:51 -04:00
$path = base_path('.env');
if (!file_exists($path)) {
$this->comment('Copying example .env file');
2024-05-07 21:52:51 -04:00
copy($path . '.example', $path);
}
if (!config('app.key')) {
$this->comment('Generating app key');
Artisan::call('key:generate');
}
$this->variables['APP_TIMEZONE'] = 'UTC';
2017-09-22 21:19:57 -05:00
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
'Application URL',
config('app.url', 'https://example.com')
2021-01-23 12:33:34 -08:00
);
2017-09-22 21:19:57 -05:00
// Make sure session cookies are set as "secure" when using HTTPS
if (str_starts_with($this->variables['APP_URL'], 'https://')) {
$this->variables['SESSION_SECURE_COOKIE'] = 'true';
2017-09-22 21:19:57 -05:00
}
$this->comment('Writing variables to .env file');
$this->writeToEnvironment($this->variables);
2017-11-04 16:40:48 -05:00
$this->info("Setup complete. Vist {$this->variables['APP_URL']}/installer to complete the installation");
2017-09-22 21:19:57 -05:00
}
}