Пример #1
1
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Install bitrix...");
     global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $arWizardConfig, $MESS;
     $bitrixRoot = $this->projectPath;
     $_SERVER["DOCUMENT_ROOT"] = $bitrixRoot;
     $_SERVER["REQUEST_URI"] = "/index.php";
     $_SERVER["QUERY_STRING"] = "";
     define("B_PROLOG_INCLUDED", true);
     ob_start();
     require_once "{$bitrixRoot}/bitrix/modules/main/install/wizard/wizard.php";
     ob_end_clean();
     $output->writeln("Step 1. Create database:");
     $wizard = new \CWizardBase("nonlux.createDb.wizard", null);
     $dbName = time() . "_db";
     $output->writeln("database name: {$dbName}");
     $data = $this->getConfig(array("agree_license", "user", "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot'));
     foreach ($data as $key => $value) {
         $wizard->SetVar($key, $value);
     }
     $step = new \CreateDBStep();
     $wizard->AddStep($step);
     $step->OnPostForm();
     $output->writeln("Done");
     require_once $bitrixRoot . '/bitrix/php_interface/dbconn.php';
     $output->writeln("Step 2. Install modules:");
     $wizard = new \CWizardBase("nonlux.installModules.wizard", null);
     $data = array_merge(array("nextStep" => "main", "nextStepStage" => "utf8"), $this->getConfig(array('bitrixRoot', "user", "password", "utf8")));
     $step = new CreateModulesStep();
     $wizard->AddStep($step);
     foreach ($data as $key => $value) {
         $wizard->SetVar($key, $value);
     }
     do {
         $output->writeln("Install " . $wizard->GetVar("nextStep") . " " . $wizard->GetVar("nextStepStage"));
         $step->OnPostForm();
         if ($wizard->GetVar("nextStep") === 'main' && $wizard->GetVar("nextStepStage") === 'files') {
             $HttpApplication = \Bitrix\Main\HttpApplication::getInstance();
             $HttpApplication->initializeBasicKernel();
             $HttpApplication->getCache()->clearCache(true);
             $GLOBALS['CACHE_MANAGER']->Clean('b_option');
             Option::clearOptions("main");
         }
     } while ($wizard->GetVar('nextStep') != '__finish');
     $output->writeln("Done");
     $USER = new \CUser();
     $policy = $USER->GetSecurityPolicy();
     $output->writeln("Step 3. Create admin:");
     $data = $this->getConfig(array('email', 'login', 'admin_password_confirm', 'admin_password', 'user_name', "utf8", 'user_surname'));
     foreach ($data as $key => $value) {
         $wizard->SetVar($key, $value);
     }
     $wizard = new \CWizardBase("nonlux.admin.wizard", null);
     $step = new \CreateAdminStep();
     $wizard->AddStep($step);
     $step->OnPostForm();
     $output->writeln("Done");
     $step = new \FinishStep();
     $step->ShowStep();
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $arWizardConfig, $MESS;
     $bitrixRoot = $this->projectPath;
     $output->writeln("Install bitrix... in  {$bitrixRoot}");
     $st = 1;
     /*
             $output->writeln("Step $st. Create database:");
             ++$st;
             $wizard = new \CWizardBase("nonlux.createDb.wizard", null);
     
             $dbName = $this->config['database'];
             $output->writeln("database name: $dbName");
             $data = $this->getConfig(array(
        "agree_license",
        "user" ,
        "password",
        "database",
        "utf8",
        "dbType",
        "host",
        "create_user",
        "create_database",
        "root_user",
        "root_password",
        'file_access_perms',
        'folder_access_perms',
        'bitrixRoot'
             ));
     
     
             foreach ($data as $key => $value) {
        $wizard->SetVar($key, $value);
             }
             $step = new \CreateDBStep();
             $wizard->AddStep($step);
             $step->OnPostForm();
             $errors=$step->GetErrors();
             if (isset($errors[0])){
        $last_error=iconv('cp1251', 'utf-8', $errors[0][0]);
        throw new \Exception($last_error);
             }
             $output->writeln("Done");
     */
     $output->writeln("Step {$st}. Generate config files:");
     ++$st;
     $data = $this->getConfig(array("agree_license", "user", "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot'));
     $settings = sprintf("<?php\nreturn array (\n        'className' => '\\\\Bitrix\\\\Main\\\\DB\\\\MysqliConnection',\n        'host' => '%s',\n        'database' => '%s',\n        'login' => '%s',\n        'password' => '%s',\n        'options' => 2,\n      );\n", $data['host'], $data['database'], $data['user'], $data['password']);
     file_put_contents($bitrixRoot . '/bitrix/.db_settings.php', $settings);
     $settings = "<?php return require(__DIR__.'/.settings_prod.php');";
     file_put_contents($bitrixRoot . '/bitrix/.settings.php', $settings);
     $output->writeln("Done");
     $_SERVER["DOCUMENT_ROOT"] = $bitrixRoot;
     $_SERVER["REQUEST_URI"] = "/index.php";
     $_SERVER["QUERY_STRING"] = "";
     define("B_PROLOG_INCLUDED", true);
     ob_start();
     require_once "{$bitrixRoot}/bitrix/modules/main/install/wizard/wizard.php";
     ob_end_clean();
     require_once $bitrixRoot . '/bitrix/php_interface/dbconn.php';
     $connection = \Bitrix\Main\Application::getConnection();
     var_dump($connection);
     $output->writeln("Step {$st}. Install modules:");
     ++$st;
     $wizard = new \CWizardBase("nonlux.installModules.wizard", null);
     $data = array_merge(array("nextStep" => "main", "nextStepStage" => "files"), $this->getConfig(array('bitrixRoot', "user", "password", "utf8")));
     $step = new CreateModulesStep();
     $wizard->AddStep($step);
     foreach ($data as $key => $value) {
         $wizard->SetVar($key, $value);
     }
     do {
         $wizard->SetVar("nextStepStage", "files");
         $output->writeln("Install " . $wizard->GetVar("nextStep") . " " . $wizard->GetVar("nextStepStage"));
         $step->OnPostForm();
         if ($wizard->GetVar("nextStep") === 'main' && $wizard->GetVar("nextStepStage") === 'files') {
             $HttpApplication = \Bitrix\Main\HttpApplication::getInstance();
             $HttpApplication->initializeBasicKernel();
             $HttpApplication->getCache()->clearCache(true);
             $GLOBALS['CACHE_MANAGER']->Clean('b_option');
             Option::clearOptions("main");
         }
     } while ($wizard->GetVar('nextStep') != '__finish');
     $output->writeln("Done");
     /*
             $USER = new \CUser;
             $policy = $USER->GetSecurityPolicy();
             $output->writeln("Step $st. Create admin:");
             ++$st;
             $data = $this->getConfig(array(
        'email',
        'login',
        'admin_password_confirm',
        'admin_password',
        'user_name',
        "utf8",
        'user_surname'
             ));
     
             foreach ($data as $key => $value) {
        $wizard->SetVar($key, $value);
             }
             $wizard = new \CWizardBase("nonlux.admin.wizard", null);
             $step = new \CreateAdminStep();
             $wizard->AddStep($step);
             $step->OnPostForm();
     
             $output->writeln("Done");
             $step = new \FinishStep();
             $step->ShowStep();
     */
 }