Flarum\Install\Console\InstallCommand::install PHP Method

install() protected method

protected install ( )
    protected function install()
    {
        try {
            $this->dbConfig = $this->dataSource->getDatabaseConfiguration();
            $validation = $this->getValidator()->make($this->dbConfig, ['driver' => 'required|in:mysql', 'host' => 'required', 'database' => 'required|string', 'username' => 'required|string', 'prefix' => 'alpha_dash|max:10']);
            if ($validation->fails()) {
                throw new Exception(implode("\n", call_user_func_array('array_merge', $validation->getMessageBag()->toArray())));
            }
            $this->baseUrl = $this->dataSource->getBaseUrl();
            $this->settings = $this->dataSource->getSettings();
            $this->adminUser = $admin = $this->dataSource->getAdminUser();
            if (strlen($admin['password']) < 8) {
                throw new Exception('Password must be at least 8 characters.');
            }
            if ($admin['password'] !== $admin['password_confirmation']) {
                throw new Exception('The password did not match its confirmation.');
            }
            if (!filter_var($admin['email'], FILTER_VALIDATE_EMAIL)) {
                throw new Exception('You must enter a valid email.');
            }
            if (!$admin['username'] || preg_match('/[^a-z0-9_-]/i', $admin['username'])) {
                throw new Exception('Username can only contain letters, numbers, underscores, and dashes.');
            }
            $this->storeConfiguration();
            $resolver = $this->application->make('Illuminate\\Database\\ConnectionResolverInterface');
            AbstractModel::setConnectionResolver($resolver);
            AbstractModel::setEventDispatcher($this->application->make('events'));
            $this->runMigrations();
            $this->writeSettings();
            $this->application->register('Flarum\\Core\\CoreServiceProvider');
            $this->seedGroups();
            $this->seedPermissions();
            $this->createAdminUser();
            $this->enableBundledExtensions();
            $this->publishAssets();
        } catch (Exception $e) {
            @unlink($this->getConfigFile());
            throw $e;
        }
    }