Skip to content

Commit dadbe3f

Browse files
committed
Add support for Joomla app version 5.1.1
1 parent 5feca85 commit dadbe3f

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
3+
namespace Hestia\WebApp\Installers\Joomla;
4+
5+
use Hestia\System\Util;
6+
use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
7+
8+
class JoomlaSetup extends BaseSetup {
9+
protected $appInfo = [
10+
"name" => "Joomla",
11+
"group" => "cms",
12+
"enabled" => true,
13+
"version" => "5.1.1",
14+
"thumbnail" => "joomla_thumb.png",
15+
];
16+
17+
protected $appname = "joomla";
18+
protected $config = [
19+
"form" => [
20+
"site_name" => [
21+
"type" => "text",
22+
"value" => "Joomla Site",
23+
"placeholder" => "Joomla Site",
24+
],
25+
"admin_username" => [
26+
"type" => "text",
27+
"value" => "admin",
28+
"placeholder" => "Admin Username",
29+
],
30+
"admin_password" => [
31+
"type" => "password",
32+
"value" => "",
33+
"placeholder" => "Admin Password",
34+
],
35+
"admin_email" => [
36+
"type" => "text",
37+
"value" => "admin@example.com",
38+
"placeholder" => "Admin Email",
39+
],
40+
"install_directory" => [
41+
"type" => "text",
42+
"value" => "",
43+
"placeholder" => "/",
44+
],
45+
],
46+
"database" => true,
47+
"resources" => [
48+
"archive" => [
49+
"src" =>
50+
"https://downloads.joomla.org/cms/joomla5/5-1-1/Joomla_5-1-1-Stable-Full_Package.zip?format=zip",
51+
],
52+
],
53+
"server" => [
54+
"php" => [
55+
"supported" => ["7.4", "8.0", "8.1", "8.2"],
56+
],
57+
],
58+
];
59+
60+
public function install(array $options = null): bool {
61+
$installDir =
62+
rtrim($this->getDocRoot(), "/") . "/" . ltrim($options["install_directory"] ?? "", "/");
63+
parent::setAppDirInstall($options["install_directory"] ?? "");
64+
parent::install($options);
65+
parent::setup($options);
66+
67+
if (!is_dir($installDir)) {
68+
throw new \Exception("Installation directory does not exist: " . $installDir);
69+
}
70+
71+
// Database credentials
72+
$dbName = $this->appcontext->user() . "_" . $options["database_name"];
73+
$dbUser = $this->appcontext->user() . "_" . $options["database_user"];
74+
$dbPass = $options["database_password"];
75+
76+
// Site and admin credentials
77+
$siteName = $options["site_name"];
78+
$adminUsername = $options["admin_username"];
79+
$adminPassword = $options["admin_password"];
80+
$adminEmail = $options["admin_email"];
81+
82+
// Initialize Joomla using the CLI
83+
$cliCmd = [
84+
"/usr/bin/php",
85+
"$installDir/installation/joomla.php",
86+
"install",
87+
"--site-name=" . $siteName,
88+
"--admin-user=" . $adminUsername,
89+
"--admin-username=" . $adminUsername,
90+
"--admin-password=" . $adminPassword,
91+
"--admin-email=" . $adminEmail,
92+
"--db-user=" . $dbUser,
93+
"--db-pass=" . $dbPass,
94+
"--db-name=" . $dbName,
95+
"--db-prefix=" . Util::generate_string(5, false) . "_",
96+
"--db-host=localhost",
97+
"--db-type=mysqli",
98+
];
99+
100+
$status = null;
101+
$this->appcontext->runUser("v-run-cli-cmd", $cliCmd, $status);
102+
103+
if ($status->code !== 0) {
104+
throw new \Exception("Failed to install Joomla using CLI: " . $status->text);
105+
}
106+
107+
return true;
108+
}
109+
}
5.33 KB
Loading

0 commit comments

Comments
 (0)