Skip to content

Commit 392bd24

Browse files
authored
Merge pull request hestiacp#4433 from ricardo777/main
Add support for Joomla app version 5.1.1
2 parents ead8627 + 07f09c4 commit 392bd24

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
"nginx" => [
55+
"template" => "joomla",
56+
],
57+
"php" => [
58+
"supported" => ["7.4", "8.0", "8.1", "8.2"],
59+
],
60+
],
61+
];
62+
63+
public function install(array $options = null): bool {
64+
$installDir =
65+
rtrim($this->getDocRoot(), "/") . "/" . ltrim($options["install_directory"] ?? "", "/");
66+
parent::setAppDirInstall($options["install_directory"] ?? "");
67+
parent::install($options);
68+
parent::setup($options);
69+
70+
if (!is_dir($installDir)) {
71+
throw new \Exception("Installation directory does not exist: " . $installDir);
72+
}
73+
74+
// Database credentials
75+
$dbName = $this->appcontext->user() . "_" . $options["database_name"];
76+
$dbUser = $this->appcontext->user() . "_" . $options["database_user"];
77+
$dbPass = $options["database_password"];
78+
79+
// Site and admin credentials
80+
$siteName = $options["site_name"];
81+
$adminUsername = $options["admin_username"];
82+
$adminPassword = $options["admin_password"];
83+
$adminEmail = $options["admin_email"];
84+
85+
// Initialize Joomla using the CLI
86+
$cliCmd = [
87+
"/usr/bin/php",
88+
"$installDir/installation/joomla.php",
89+
"install",
90+
"--site-name=" . $siteName,
91+
"--admin-user=" . $adminUsername,
92+
"--admin-username=" . $adminUsername,
93+
"--admin-password=" . $adminPassword,
94+
"--admin-email=" . $adminEmail,
95+
"--db-user=" . $dbUser,
96+
"--db-pass=" . $dbPass,
97+
"--db-name=" . $dbName,
98+
"--db-prefix=" . Util::generate_string(5, false) . "_",
99+
"--db-host=localhost",
100+
"--db-type=mysqli",
101+
];
102+
103+
$status = null;
104+
$this->appcontext->runUser("v-run-cli-cmd", $cliCmd, $status);
105+
106+
if ($status->code !== 0) {
107+
throw new \Exception("Failed to install Joomla using CLI: " . $status->text);
108+
}
109+
110+
return true;
111+
}
112+
}
5.33 KB
Loading

0 commit comments

Comments
 (0)