1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

Introduzione procedura di configurazione

This commit is contained in:
Dasc3er
2021-02-19 11:54:03 +01:00
parent 73129be4a7
commit b93ee1a7f6
35 changed files with 1432 additions and 166 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
class EnsureEnvFile
{
/**
* Handle an incoming request.
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
// Copia del file .env dal formato standard
$env_file = base_path('.env');
if (!file_exists($env_file)) {
copy(base_path('.env.example'), $env_file);
if (!file_exists($env_file)) {
return response('Missing .env file');
}
}
// Generazione automatica delle key Laravel
if (empty(env('APP_KEY'))) {
Artisan::call('key:generate');
header('Refresh: 0;');
return response('Missing app key');
}
return $next($request);
}
}