feat: Implement an installation process including a setup UI, database migrations, and admin account creation.

This commit is contained in:
dyzulk
2026-01-17 13:57:08 +07:00
parent e8ffea2c58
commit b245f31236
4 changed files with 55 additions and 1 deletions

View File

@@ -15,8 +15,12 @@ class InstallController extends Controller {
header('Location: /login');
exit;
}
$permissions = $this->checkPermissions();
return $this->view('install');
return $this->view('install', [
'permissions' => $permissions
]);
}
public function process() {
@@ -25,6 +29,13 @@ class InstallController extends Controller {
exit;
}
$permissions = $this->checkPermissions();
if (!$permissions['db_writable'] || !$permissions['root_writable']) {
\App\Helpers\FlashHelper::set('error', 'Izin Ditolak', 'Pastikan folder app/Database dan root direktori dapat ditulis oleh server web.');
header('Location: /install');
exit;
}
$username = $_POST['username'] ?? 'admin';
$password = $_POST['password'] ?? 'admin';
@@ -63,6 +74,17 @@ class InstallController extends Controller {
}
}
private function checkPermissions() {
$dbDir = ROOT . '/app/Database';
$envFile = ROOT . '/.env';
return [
'db_writable' => is_writable($dbDir),
'env_writable' => file_exists($envFile) ? is_writable($envFile) : is_writable(ROOT),
'root_writable' => is_writable(ROOT)
];
}
private function isInstalled() {
// Check if .env exists and APP_KEY is set to something other than the default/example
$envPath = ROOT . '/.env';