本文整理汇总了PHP中InstallUtil::writeConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallUtil::writeConfiguration方法的具体用法?PHP InstallUtil::writeConfiguration怎么用?PHP InstallUtil::writeConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InstallUtil
的用法示例。
在下文中一共展示了InstallUtil::writeConfiguration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runInstallation
/**
* Given an installSettingsForm, run the install including the schema creation and default data load. This is
* used by the interactice install and the command line install.
* @param object $form
* @param object $messageStreamer
*/
public static function runInstallation($form, &$messageStreamer)
{
assert('$form instanceof InstallSettingsForm');
assert('$messageStreamer instanceof MessageStreamer');
if (defined('IS_TEST')) {
$perInstanceFilename = "perInstanceTest.php";
$debugFilename = "debugTest.php";
} else {
@set_time_limit(1200);
$perInstanceFilename = "perInstance.php";
$debugFilename = "debug.php";
}
$messageStreamer->add(Zurmo::t('InstallModule', 'Connecting to Database.'));
InstallUtil::connectToDatabase($form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort);
ForgetAllCacheUtil::forgetAllCaches();
$messageStreamer->add(Zurmo::t('InstallModule', 'Dropping existing tables.'));
InstallUtil::dropAllTables();
$messageStreamer->add(Zurmo::t('InstallModule', 'Creating super user.'));
InstallUtil::createSuperUser('super', $form->superUserPassword);
$messageLogger = new MessageLogger($messageStreamer);
Yii::app()->custom->runBeforeInstallationAutoBuildDatabase($messageLogger);
$messageStreamer->add(Zurmo::t('InstallModule', 'Starting database schema creation.'));
$startTime = microtime(true);
$messageStreamer->add('debugOn:' . BooleanUtil::boolToString(YII_DEBUG));
$messageStreamer->add('phpLevelCaching:' . BooleanUtil::boolToString(PHP_CACHING_ON));
$messageStreamer->add('memcacheLevelCaching:' . BooleanUtil::boolToString(MEMCACHE_ON));
InstallUtil::autoBuildDatabase($messageLogger);
$endTime = microtime(true);
$messageStreamer->add(Zurmo::t('InstallModule', 'Total autobuild time: {formattedTime} seconds.', array('{formattedTime}' => number_format($endTime - $startTime, 3))));
if (SHOW_QUERY_DATA) {
$messageStreamer->add(PageView::getTotalAndDuplicateQueryCountContent());
$messageStreamer->add(PageView::makeNonHtmlDuplicateCountAndQueryContent());
}
$messageStreamer->add(Zurmo::t('InstallModule', 'Database schema creation complete.'));
$messageStreamer->add(Zurmo::t('InstallModule', 'Rebuilding Permissions.'));
ReadPermissionsOptimizationUtil::rebuild();
$messageStreamer->add(Zurmo::t('InstallModule', 'Freezing database.'));
InstallUtil::freezeDatabase();
$messageStreamer->add(Zurmo::t('InstallModule', 'Writing Configuration File.'));
InstallUtil::writeConfiguration(INSTANCE_ROOT, $form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort, $form->memcacheHostname, (int) $form->memcachePortNumber, true, Yii::app()->language, $perInstanceFilename, $debugFilename, $form->hostInfo, $form->scriptUrl, $form->submitCrashToSentry);
$messageStreamer->add(Zurmo::t('InstallModule', 'Setting up default data.'));
DefaultDataUtil::load($messageLogger);
Yii::app()->custom->runAfterInstallationDefaultDataLoad($messageLogger);
// Send notification to super admin to delete test.php file in case if this
// installation is used in production mode.
$message = new NotificationMessage();
$message->textContent = Zurmo::t('InstallModule', 'If this website is in production mode, please remove the app/test.php file.');
$rules = new RemoveApiTestEntryScriptFileNotificationRules();
NotificationsUtil::submit($message, $rules);
// If minify is disabled, inform user that they should fix issues and enable minify
$setIncludePathServiceHelper = new SetIncludePathServiceHelper();
if (!$setIncludePathServiceHelper->runCheckAndGetIfSuccessful()) {
$message = new NotificationMessage();
$message->textContent = Zurmo::t('InstallModule', 'Minify has been disabled due to a system issue. Try to resolve the problem and re-enable Minify.');
$rules = new EnableMinifyNotificationRules();
NotificationsUtil::submit($message, $rules);
}
InstallUtil::setZurmoTokenAndWriteToPerInstanceFile(INSTANCE_ROOT);
ZurmoPasswordSecurityUtil::setPasswordSaltAndWriteToPerInstanceFile(INSTANCE_ROOT);
$messageStreamer->add(Zurmo::t('InstallModule', 'Installation Complete.'));
}
示例2: testWriteConfiguration
public function testWriteConfiguration()
{
$instanceRoot = INSTANCE_ROOT;
$perInstanceConfigFileDist = "{$instanceRoot}/protected/config/perInstanceDIST.php";
$perInstanceConfigFile = "{$instanceRoot}/protected/config/perInstanceTest.php";
$originalPerInstanceConfiguration = file_get_contents($perInstanceConfigFile);
copy($perInstanceConfigFileDist, $perInstanceConfigFile);
$perInstanceConfiguration = file_get_contents($perInstanceConfigFile);
$debugConfigFileDist = "{$instanceRoot}/protected/config/debugDIST.php";
$debugConfigFile = "{$instanceRoot}/protected/config/debugTest.php";
$originalDebugConfiguration = file_get_contents($debugConfigFile);
copy($debugConfigFileDist, $debugConfigFile);
$debugConfiguration = file_get_contents($debugConfigFile);
$this->assertRegExp('/\\$debugOn = false;/', $debugConfiguration);
try {
InstallUtil::writeConfiguration($instanceRoot, 'mysql', 'databases.r-us.com', 'wacky', 'wacko', 'wacked', 3306, 'memcache.jason.com', 5432, false, 'es', 'perInstanceTest.php', 'debugTest.php', '', '');
$debugConfiguration = file_get_contents($debugConfigFile);
$perInstanceConfiguration = file_get_contents($perInstanceConfigFile);
$this->assertRegExp('/\\$debugOn = false;/', $debugConfiguration);
$this->assertRegExp('/\\$language = \'es\';/', $perInstanceConfiguration);
$this->assertRegExp('/\\$connectionString = \'mysql:host=databases.r-us.com;port=3306;dbname=wacky\';/', $perInstanceConfiguration);
$this->assertRegExp('/\\$username = \'wacko\';/', $perInstanceConfiguration);
$this->assertRegExp('/\\$password = \'wacked\';/', $perInstanceConfiguration);
$this->assertRegExp('/\'host\' => \'memcache.jason.com\',\\n' . ' \'port\' => 5432,/', $perInstanceConfiguration);
$this->assertNotRegExp('/\\/\\/ REMOVE THE REMAINDER/', $perInstanceConfiguration);
} catch (Exception $e) {
if (isset($debugConfiguration)) {
echo $debugConfiguration;
}
if (isset($perInstanceConfiguration)) {
echo $perInstanceConfiguration;
}
}
// finally
// {
unlink($debugConfigFile);
unlink($perInstanceConfigFile);
file_put_contents($perInstanceConfigFile, $originalPerInstanceConfiguration);
file_put_contents($debugConfigFile, $originalDebugConfiguration);
// }
if (isset($e)) {
throw $e;
}
}