Elgg  Version 6.1
InstallCommand.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cli;
4 
9 
13 class InstallCommand extends BaseCommand {
14 
18  protected function configure() {
19  $this->setName('install')
20  ->setDescription('Install Elgg using a configuration file or interactive questions')
21  ->addOption('config', 'c', InputOption::VALUE_OPTIONAL,
22  'Path to php file that returns an array with installation configuration'
23  )
24  ->addOption('no-plugins', null, InputOption::VALUE_NONE,
25  'Prevents activation of bundled plugins'
26  );
27  }
28 
32  protected function execute(InputInterface $input, OutputInterface $output) {
33  $this->input = $input;
34  $this->output = $output;
35 
36  $config = $this->option('config');
37  if ($config && file_exists(realpath($config))) {
38  $params = include $config;
39  } else {
40  $params = [
44  'displayname' => 'Administrator',
45  'username' => $this->ask('Enter admin username: ', 'admin'),
46  'password' => $this->ask('Enter admin password: ', null, true),
47  'email' => $email = $this->ask('Enter admin email: '),
51  'dbhost' => $this->ask('Enter database host: ', 'localhost'),
52  'dbport' => $this->ask('Enter database port: ', '3306'),
53  'dbuser' => $this->ask('Enter database username: '),
54  'dbpassword' => $this->ask('Enter database password: ', null, true),
55  'dbname' => $this->ask('Enter database name: '),
56  'dbprefix' => $this->ask('Enter database prefix (for example: elgg_): ', '', false, false),
60  'sitename' => $this->ask('Enter site name: '),
61  'siteemail' => $this->ask('Enter site email: ', $email),
62  'wwwroot' => $this->ask('Enter site URL (including protocol http|https and a trailing /): '),
63  'dataroot' => $this->ask('Enter data directory path: '),
64  'timezone' => 'UTC',
65  ];
66  }
67 
68  if ($this->option('no-plugins')) {
69  $params['activate_plugins'] = false;
70  }
71 
72  try {
73  $installer = new \ElggInstaller();
74  $htaccess = !is_file(\Elgg\Project\Paths::project() . '.htaccess');
75  $installer->batchInstall($params, $htaccess);
76  } catch (InstallationException $ex) {
77  $this->dumpRegisters();
78  $this->error($ex);
79 
80  return self::FAILURE;
81  }
82 
84 
85  $release = elgg_get_release();
86 
87  $this->notice("Elgg {$release} install successful");
88  $this->notice('wwwroot: ' . elgg_get_site_url());
89  $this->notice('dataroot: ' . elgg_get_data_path());
90  $this->notice('cacheroot: ' . elgg_get_cache_path());
91  $this->notice('assetroot: ' . elgg_get_asset_path());
92 
93  return self::SUCCESS;
94  }
95 }
static project()
Get the project root (where composer is installed) path with "/".
Definition: Paths.php:25
elgg_get_release()
Get the current Elgg release.
elgg_get_asset_path()
Get the asset cache directory path for this installation, ending with slash.
$params
Saves global plugin settings.
Definition: save.php:13
ask($question, $default=null, $hidden=false, $required=true)
Ask a question.
Definition: BaseCommand.php:44
Adds interaction to a console command.
Definition: BaseCommand.php:18
error($message)
Print an error.
$email
Definition: change_email.php:7
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
notice($message)
Print a notce.
Updates the basic settings for the primary site object.
static start()
Start and boot the core.
dumpRegisters()
Dump and output system and error messages.
elgg_get_cache_path()
Get the cache directory path for this installation, ending with slash.
Thrown when there is a major problem with the installation.
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
elgg-cli install [–config]
elgg_get_data_path()
Get the data directory path for this installation, ending with slash.
execute(InputInterface $input, OutputInterface $output)
{}
option($name)
Returns option value.