-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.3] Add a CLI installation for Joomla (#38325)
* Initial code for a CLI installation * First PoC * Lots of cleanup * Finalising CLI installer * Deleting install folder after installation * Codestyle * Fixing path of API test install * Update installation/INSTALL Co-authored-by: Brian Teeman <brian@teeman.net> * Codestyle * Docblocks * Wording * Fixing db prefix for API tests * Fixing Postgres API tests * Further fixes to API tests * Some cleanup * Fixing API tests one last time * Docblock formatting * Resorting fields * Improving progress indicator messages * Disable remote DB check for CLI installation * Fixing check * Introducing _JCLI_INSTALLATION constant for DB check * Hiding password entries on CLI * hide admin psw * show db_prefix show db_prefix in interacting mode too * Adding check for configuration.php present * Allowing for empty db password * Deleting installation folder only when not in dev mode * Codestyle * Converting strings to ini file * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/src/Console/InstallCommand.php Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/src/Console/InstallCommand.php Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/src/Console/InstallCommand.php Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/src/Console/InstallCommand.php Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/src/Console/InstallCommand.php Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/language/en-GB/joomla.cli.ini Co-authored-by: Brian Teeman <brian@teeman.net> * Update installation/INSTALL Co-authored-by: Brian Teeman <brian@teeman.net> * Further bugfixes * Cleaning up available RDBMS options * Catching error when connecting to database * Removing false db type * Fixing case of attribute * Removing unnecessary methods from CliInstallationApplication * Fixing string * Sorting translation strings for CLI and adding shortened error message * Fixing docblocks and use statement * Adding Allons suggestions * Fixing use statements * Using language object from app * Remove unnecessary method * Fixing language object * Removing . at the end of sentences since they are followed by a : anyway * Use - instead of _ in the parameters * Fixing api tests Co-authored-by: Brian Teeman <brian@teeman.net> Co-authored-by: Nicola Galgano <optimus4joomla@gmail.com> Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
- Loading branch information
1 parent
8136847
commit f340734
Showing
16 changed files
with
940 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Installation | ||
* @subpackage Application | ||
* | ||
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
// Define the base path and require the other defines | ||
define('JPATH_BASE', dirname(__DIR__)); | ||
|
||
require_once __DIR__ . '/defines.php'; | ||
|
||
// Check for presence of vendor dependencies not included in the git repository | ||
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT . '/media/vendor')) { | ||
echo 'It looks like you are trying to run Joomla! from our git repository.' . PHP_EOL; | ||
echo 'To do so requires you complete a couple of extra steps first.' . PHP_EOL; | ||
echo 'Please see https://docs.joomla.org/Special:MyLanguage/J4.x:Setting_Up_Your_Local_Environment for further details.' . PHP_EOL; | ||
|
||
exit; | ||
} | ||
|
||
// Get the framework. | ||
require_once __DIR__ . '/framework.php'; | ||
|
||
// Check if the default log directory can be written to, add a logger for errors to use it | ||
if (is_writable(JPATH_ADMINISTRATOR . '/logs')) { | ||
\Joomla\CMS\Log\Log::addLogger( | ||
[ | ||
'format' => '{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}', | ||
'text_file' => 'error.php' | ||
], | ||
\Joomla\CMS\Log\Log::ALL, | ||
['error'] | ||
); | ||
} | ||
|
||
// Register the Installation application | ||
JLoader::registerNamespace('Joomla\\CMS\\Installation', JPATH_INSTALLATION . '/src', false, false); | ||
|
||
// Get the dependency injection container | ||
$container = \Joomla\CMS\Factory::getContainer(); | ||
$container->registerServiceProvider(new \Joomla\CMS\Installation\Service\Provider\Application()); | ||
|
||
/* | ||
* Alias the session service keys to the CLI session service as that is the primary session backend for this application | ||
* | ||
* In addition to aliasing "common" service keys, we also create aliases for the PHP classes to ensure autowiring objects | ||
* is supported. This includes aliases for aliased class names, and the keys for aliased class names should be considered | ||
* deprecated to be removed when the class name alias is removed as well. | ||
*/ | ||
$container->alias('session', 'session.cli') | ||
->alias('JSession', 'session.cli') | ||
->alias(\Joomla\CMS\Session\Session::class, 'session.cli') | ||
->alias(\Joomla\Session\Session::class, 'session.cli') | ||
->alias(\Joomla\Session\SessionInterface::class, 'session.cli'); | ||
|
||
// Instantiate and execute the application | ||
$container->get(\Joomla\CMS\Installation\Application\CliInstallationApplication::class)->execute(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Installation | ||
* | ||
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
/** | ||
* NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message | ||
*/ | ||
|
||
/** | ||
* Define the application's minimum supported PHP version as a constant so it can be referenced within the application. | ||
*/ | ||
define('JOOMLA_MINIMUM_PHP', '7.2.5'); | ||
|
||
if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<')) { | ||
echo 'Sorry, your PHP version is not supported.' . PHP_EOL; | ||
echo 'Your command line php needs to be version ' . JOOMLA_MINIMUM_PHP . ' or newer to run the Joomla! CLI Tools' . PHP_EOL; | ||
echo 'The version of PHP currently running this code, at the command line, is PHP version ' . PHP_VERSION . '.' . PHP_EOL; | ||
echo 'Please note, the version of PHP running your commands here, may be different to the version that is used by '; | ||
echo 'your web server to run the Joomla! Web Application' . PHP_EOL; | ||
|
||
exit; | ||
} | ||
|
||
/** | ||
* Constant that is checked in included files to prevent direct access. | ||
* define() is used rather than "const" to not error for PHP 5.2 and lower | ||
*/ | ||
define('_JEXEC', 1); | ||
|
||
// Constant to identify the CLI installation | ||
define('_JCLI_INSTALLATION', 1); | ||
|
||
// Run the application - All executable code should be triggered through this file | ||
require_once dirname(__FILE__) . '/includes/cli.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
INSTL_ADMIN_EMAIL_DESC="Enter the email address of the website Super User" | ||
INSTL_ADMIN_EMAIL_DESC_SHORT="Email address of the website's Super User account" | ||
INSTL_ADMIN_PASSWORD_DESC="Set the password for your Super User account" | ||
INSTL_ADMIN_PASSWORD_DESC_SHORT="Password of your Super User account" | ||
INSTL_ADMIN_USERNAME_DESC="Set the username for your Super User account" | ||
INSTL_ADMIN_USERNAME_DESC_SHORT="Username of your Super User account" | ||
INSTL_ADMIN_USER_DESC="Enter the real name of your Super User" | ||
INSTL_ADMIN_USER_DESC_SHORT="Real name of the Super User account" | ||
INSTL_DATABASE_COULD_NOT_CONNECT="%s" | ||
INSTL_DATABASE_ENCRYPTION_CA_LABEL="Path to CA file to verify encryption against" | ||
INSTL_DATABASE_ENCRYPTION_CA_LABEL_SHORT="Path to CA file to verify encryption against" | ||
INSTL_DATABASE_ENCRYPTION_CERT_LABEL="Path to the SSL certificate for the database connection. Requires encryption to be set to 2" | ||
INSTL_DATABASE_ENCRYPTION_CERT_LABEL_SHORT="Path to the SSL certificate for the database connection. Requires encryption to be set to 2" | ||
INSTL_DATABASE_ENCRYPTION_CIPHER_LABEL="Supported Cipher Suite (optional)" | ||
INSTL_DATABASE_ENCRYPTION_CIPHER_LABEL_SHORT="Supported Cipher Suite (optional)" | ||
INSTL_DATABASE_ENCRYPTION_KEY_LABEL="SSL key for the database connection. Requires encryption to be set to 2" | ||
INSTL_DATABASE_ENCRYPTION_KEY_LABEL_SHORT="SSL key for the database connection. Requires encryption to be set to 2" | ||
INSTL_DATABASE_ENCRYPTION_MODE_LABEL="Encryption for the database connection. Values: 0=None, 1=One way, 2=Two way" | ||
INSTL_DATABASE_ENCRYPTION_MODE_LABEL="Encryption for the database connection. Values: 0=None, 1=One way, 2=Two way" | ||
INSTL_DATABASE_ENCRYPTION_VERIFY_SERVER_CERT_LABEL="Verify SSL certificate for database connection. Values: 0=No, 1=Yes. Requires encryption to be set to 1 or 2" | ||
INSTL_DATABASE_ENCRYPTION_VERIFY_SERVER_CERT_LABEL_SHORT="Verify SSL certificate for database connection. Values: 0=No, 1=Yes. Requires encryption to be set to 1 or 2" | ||
INSTL_DATABASE_HOST_DESC="Database host" | ||
INSTL_DATABASE_HOST_DESC_SHORT="Database host" | ||
INSTL_DATABASE_NAME_DESC="Database name" | ||
INSTL_DATABASE_NAME_DESC_SHORT="Database name" | ||
INSTL_DATABASE_PASSWORD_DESC="Database password" | ||
INSTL_DATABASE_PASSWORD_DESC_SHORT="Database password" | ||
INSTL_DATABASE_PREFIX_DESC="Prefix for the database tables" | ||
INSTL_DATABASE_PREFIX_DESC_SHORT="Prefix for the database tables" | ||
INSTL_DATABASE_TYPE_DESC="Database type. Supported: mysql, mysqli, pgsql" | ||
INSTL_DATABASE_TYPE_DESC_SHORT="Database type. Supported by Joomla: mysql (=MySQL (PDO)), mysqli (=MySQLi), pgsql (=PostgreSQL (PDO))" | ||
INSTL_DATABASE_USER_DESC="Database username" | ||
INSTL_DATABASE_USER_DESC_SHORT="Database username" | ||
INSTL_SITE_NAME_DESC="Enter the name of your Joomla site" | ||
INSTL_SITE_NAME_DESC_SHORT="Name of the website" |
Oops, something went wrong.