1
0
mirror of https://github.com/flarum/core.git synced 2025-10-18 18:26:07 +02:00

Implement web installer

This commit is contained in:
Toby Zerner
2015-08-17 14:12:02 +09:30
parent 17dbeefabe
commit 1052aa55ea
10 changed files with 596 additions and 45 deletions

View File

@@ -2,50 +2,76 @@
class DefaultData implements ProvidesData
{
protected $databaseConfiguration = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'flarum_console',
'username' => 'root',
'password' => 'root',
'prefix' => '',
];
protected $adminUser = [
'username' => 'admin',
'password' => 'admin',
'email' => 'admin@example.com',
];
protected $settings = [
'admin_url' => 'http://flarum.dev/admin',
'allow_post_editing' => 'reply',
'allow_renaming' => '10',
'allow_sign_up' => '1',
'api_url' => 'http://flarum.dev/api',
'base_url' => 'http://flarum.dev',
'custom_less' => '',
'default_locale' => 'en',
'default_route' => '/all',
'extensions_enabled' => '[]',
'forum_title' => 'Development Forum',
'forum_description' => '',
'mail_driver' => 'mail',
'mail_from' => 'noreply@flarum.dev',
'theme_colored_header' => '0',
'theme_dark_mode' => '0',
'theme_primary_color' => '#29415E',
'theme_secondary_color' => '#29415E',
'welcome_message' => 'This is beta software and you should not use it in production.',
'welcome_title' => 'Welcome to Development Forum',
];
public function getDatabaseConfiguration()
{
return [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'flarum_console',
'username' => 'root',
'password' => 'root',
'prefix' => '',
];
return $this->databaseConfiguration;
}
public function setDatabaseConfiguration(array $databaseConfiguration)
{
$this->databaseConfiguration = $databaseConfiguration;
}
public function getAdminUser()
{
return [
'username' => 'admin',
'password' => 'admin',
'email' => 'admin@example.com',
];
return $this->adminUser;
}
public function setAdminUser(array $adminUser)
{
$this->adminUser = $adminUser;
}
public function getSettings()
{
return [
'admin_url' => 'http://flarum.dev/admin',
'allow_post_editing' => 'reply',
'allow_renaming' => '10',
'allow_sign_up' => '1',
'api_url' => 'http://flarum.dev/api',
'base_url' => 'http://flarum.dev',
'custom_less' => '',
'default_locale' => 'en',
'default_route' => '/all',
'extensions_enabled' => '[]',
'forum_title' => 'Development Forum',
'forum_description' => '',
'mail_driver' => 'mail',
'mail_from' => 'noreply@flarum.dev',
'theme_colored_header' => '0',
'theme_dark_mode' => '0',
'theme_primary_color' => '#29415E',
'theme_secondary_color' => '#29415E',
'welcome_message' => 'This is beta software and you should not use it in production.',
'welcome_title' => 'Welcome to Development Forum',
];
return $this->settings;
}
public function setSettings(array $settings)
{
$this->settings = $settings;
}
public function setSetting($key, $value)
{
$this->settings[$key] = $value;
}
}

View File

@@ -59,13 +59,20 @@ class InstallCommand extends Command
protected function init()
{
if ($this->input->getOption('defaults')) {
$this->dataSource = new DefaultData();
} else {
$this->dataSource = new DataFromUser($this->input, $this->output, $this->getHelperSet()->get('question'));
if ($this->dataSource === null) {
if ($this->input->getOption('defaults')) {
$this->dataSource = new DefaultData();
} else {
$this->dataSource = new DataFromUser($this->input, $this->output, $this->getHelperSet()->get('question'));
}
}
}
public function setDataSource(ProvidesData $dataSource)
{
$this->dataSource = $dataSource;
}
protected function install()
{
$this->storeConfiguration();
@@ -85,6 +92,7 @@ class InstallCommand extends Command
$this->createAdminUser();
$this->enableBundledExtensions();
}
protected function storeConfiguration()
@@ -106,9 +114,13 @@ class InstallCommand extends Command
],
];
$this->info('Writing config');
$this->info('Testing config');
$this->container->instance('flarum.config', $config);
$this->container->make('flarum.db');
$this->info('Writing config');
file_put_contents(
base_path('../config.php'),
'<?php return '.var_export($config, true).';'
@@ -208,6 +220,23 @@ class InstallCommand extends Command
$user->groups()->sync([1]);
}
protected function enableBundledExtensions()
{
$extensions = $this->container->make('Flarum\Support\ExtensionManager');
$migrator = $extensions->getMigrator();
foreach ($extensions->getInfo() as $extension) {
$this->info('Enabling extension: '.$extension->name);
$extensions->enable($extension->name);
foreach ($migrator->getNotes() as $note) {
$this->info($note);
}
}
}
/**
* @return \Illuminate\Database\ConnectionInterface
*/