public static function poweredBy($text = '', $url = '')
 {
     if (empty($text)) {
         $text = 'Powered By Startup-Kit - ' . InstallerModule::getVersion();
     }
     if (empty($url)) {
         $url = 'https://github.com/abhi1693/yii2-app-advanced-startup-kit';
     }
     return Html::a(Html::encode($text), $url);
 }
示例#2
0
	<body>
	<?php 
$this->beginBody();
?>
	<div class="container"
	     style="margin: 0 auto;max-width: 700px;padding-top: 80px;">
		<?php 
echo $content;
?>

		<div class="text">
			<p class="pull-left"><?php 
echo InstallerModule::poweredBy();
?>
</p>

			<p class="pull-right">Created
				By <?php 
echo Html::mailto(InstallerModule::getAuthor(), InstallerModule::getAuthorEmail());
?>
</p>
		</div>
	</div>

	<?php 
$this->endBody();
?>
	</body>
	</html>
<?php 
$this->endPage();
 /**
  * Last Step, finish up the installation
  */
 public function actionFinished()
 {
     // Rewrite whole configuration file, also sets application
     // in installed state.
     Configuration::rewriteConfiguration();
     // Set to installed
     InstallerModule::setInstalled();
     return $this->render('finished');
 }
<?php

return ['vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'modules' => ['user' => ['class' => \abhimanyu\user\UserModule::className(), 'layout' => '@backend/views/layouts/admin'], 'installer' => ['class' => \abhimanyu\installer\InstallerModule::className()], 'gridview' => ['class' => \kartik\grid\Module::className()]], 'components' => ['db' => ['class' => \yii\db\Connection::className(), 'dsn' => 'mysql:host=localhost;dbname='], 'user' => ['identityClass' => \abhimanyu\user\models\UserIdentity::className(), 'loginUrl' => ['/user/auth/login']], 'config' => ['class' => \abhimanyu\config\components\Config::className()], 'urlManager' => ['enablePrettyUrl' => TRUE, 'showScriptName' => FALSE]], 'params' => ['installed' => FALSE]];
 public function actionDatabase()
 {
     $config = Configuration::get();
     $param = Configuration::getParam();
     $form = new DatabaseSettingForm();
     if ($form->load(Yii::$app->request->post())) {
         if ($form->validate()) {
             $dsn = "mysql:host=" . $form->hostname . ";dbname=" . $form->database;
             // Create Test DB Connection
             Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => $dsn, 'username' => $form->username, 'password' => $form->password, 'charset' => 'utf8']);
             try {
                 Yii::$app->db->open();
                 // Check DB Connection
                 if (InstallerModule::checkDbConnection()) {
                     // Write Config
                     $config['components']['db']['class'] = Connection::className();
                     $config['components']['db']['dsn'] = $dsn;
                     $config['components']['db']['username'] = $form->username;
                     $config['components']['db']['password'] = $form->password;
                     $config['components']['db']['charset'] = 'utf8';
                     // Write config for future use
                     $param['installer']['db']['installer_hostname'] = $form->hostname;
                     $param['installer']['db']['installer_database'] = $form->database;
                     $param['installer']['db']['installer_username'] = $form->username;
                     Configuration::set($config);
                     Configuration::setParam($param);
                     Yii::$app->getSession()->setFlash('success', 'Database settings saved');
                 } else {
                     Yii::$app->getSession()->setFlash('danger', 'Incorrect configuration');
                 }
             } catch (Exception $e) {
                 Yii::$app->getSession()->setFlash('danger', $e->getMessage());
             }
         }
     } else {
         if (isset($param['installer']['db']['installer_hostname'])) {
             $form->hostname = $param['installer']['db']['installer_hostname'];
         }
         if (isset($param['installer']['db']['installer_database'])) {
             $form->database = $param['installer']['db']['installer_database'];
         }
         if (isset($param['installer']['db']['installer_username'])) {
             $form->username = $param['installer']['db']['installer_username'];
         }
     }
     return $this->render('database', ['model' => $form]);
 }
 /**
  * The init action imports the database structure & initial data
  */
 public function actionInit()
 {
     if (!InstallerModule::checkDbConnection()) {
         Yii::$app->db->open();
     }
     // Flush the caches
     if (Yii::$app->cache) {
         Yii::$app->cache->flush();
     }
     // todo make migration better
     $data = file_get_contents(dirname(__DIR__) . '/migrations/data.sql');
     Yii::$app->db->createCommand($data)->execute();
     return $this->redirect(Yii::$app->urlManager->createUrl('//installer/config/index'));
 }