| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 3 define('AK_URL_REWRITE_ENABLED', true); 4 define('AK_SITE_URL_SUFFIX', '/'); 5 6 require_once (AK_LIB_DIR.DS.'AkInstaller.php'); 7 8 @ini_set("include_path",(AK_BASE_DIR.DS.'vendor'.DS.'pear'.PATH_SEPARATOR.ini_get("include_path"))); 9 10 11 Ak::import('FrameworkSetup'); 12 13 14 set_time_limit(0); 15 error_reporting(E_ALL); 16 17 require_once(AK_CONTRIB_DIR.DS.'adodb'.DS.'adodb.inc.php'); 18 require_once (AK_VENDOR_DIR.DS.'pear'.DS.'Console'.DS.'Getargs.php'); 19 20 21 function prompt_var($question, $default_value = null, $cli_value = null) 22 { 23 global $options; 24 if(empty($options['interactive']) && isset($cli_value)){ 25 return $cli_value; 26 }else{ 27 return AkInstaller::promptUserVar($question, array('default'=>$default_value, 'optional'=>true)); 28 } 29 } 30 31 function set_db_user_and_pass(&$FrameworkSetup, &$db_user, &$db_pass, &$db_type, $defaults = true){ 32 global $options; 33 $db_type = prompt_var('Dabase type', 'mysql', $defaults?@$options['database']:null); 34 $db_user = prompt_var('Database user', $FrameworkSetup->suggestUserName(), $defaults?@$options['user']:null); 35 $db_pass = prompt_var('Database password', '', $defaults?@$options['password']:null); 36 37 38 if(!@NewADOConnection("$db_type://$db_user:$db_pass@localhost")){ 39 echo Ak::t('Could not connect to the database'."\n"); 40 set_db_user_and_pass($FrameworkSetup, $db_user, $db_pass, $db_type, false); 41 } 42 43 } 44 45 46 47 48 49 $config = array( 50 51 'user' => array( 52 'short' => 'u', 53 'max' => 1, 54 'min' => 1, 55 'default' => 'root', 56 'desc' => 'Database user'), 57 58 'password' => array( 59 'short' => 'p', 60 'max' => 1, 61 'min' => 1, 62 'default' => '', 63 'desc' => 'Database password'), 64 65 'database' => array( 66 'short' => 'd', 67 'max' => 1, 68 'min' => 1, 69 'default' => 'mysql', 70 'desc' => 'Database type'), 71 72 'name' => array( 73 'short' => 'n', 74 'max' => 1, 75 'min' => 1, 76 'default' => AkInflector::underscore(basename(AK_BASE_DIR)), 77 'desc' => 'Database name. This is the name of your database. It will be prefixed with _dev and _tests for non production environments.'), 78 79 'languages' => array( 80 'short' => 'l', 81 'max' => 1, 82 'min' => 1, 83 'default' => 'en', 84 'desc' => 'Language codes for this application.'), 85 86 'interactive' => array( 87 'short' => 'i', 88 'max' => 0, 89 'min' => 0, 90 'default' => false, 91 'desc' => 'Interactive mode.'), 92 93 ); 94 95 96 $args =& Console_Getargs::factory($config); 97 98 if (PEAR::isError($args)) { 99 if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER) { 100 echo Console_Getargs::getHelp($config, null, $args->getMessage())."\n"; 101 } else if ($args->getCode() === CONSOLE_GETARGS_HELP) { 102 echo @Console_Getargs::getHelp($config)."\n"; 103 } 104 exit; 105 } 106 107 $options = $args->getValues(); 108 109 110 111 112 $FrameworkSetup = new FrameworkSetup(); 113 $FrameworkSetup->setDefaultOptions(); 114 $FrameworkSetup->getAvailableDatabases(); 115 116 $app_name = empty($options['interactive']) ? 117 $options['name'] : 118 prompt_var('Database name. This is the name of your database. It will be prefixed with _dev and _tests for non production environments.', $options['name']); 119 120 $db_user = $db_pass = $db_type = ''; 121 122 123 124 125 set_db_user_and_pass($FrameworkSetup, $db_user, $db_pass, $db_type); 126 127 128 $FrameworkSetup->setDatabaseUser($db_user, 'admin'); 129 $FrameworkSetup->setDatabasePassword($db_pass, 'admin'); 130 $FrameworkSetup->setDatabaseType($db_type); 131 132 foreach (array('development','production','testing') as $mode){ 133 $db_postfix = ($mode=='production'?'': 134 ($mode=='development'?'_dev': 135 ($mode=='testing'?'_tests':'_'.$mode))); 136 137 $FrameworkSetup->setDatabaseName( 138 prompt_var(ucfirst($mode).' database name', 139 $app_name.$db_postfix, @$options['name'].$db_postfix), $mode); 140 141 if($FrameworkSetup->getDatabaseType($mode) != 'sqlite'){ 142 $FrameworkSetup->setDatabaseHost('localhost', $mode); 143 $FrameworkSetup->setDatabaseUser($db_user, $mode); 144 $FrameworkSetup->setDatabasePassword($db_pass, $mode); 145 $FrameworkSetup->createDatabase($mode); 146 } 147 } 148 149 $FrameworkSetup->setLocales(prompt_var('Application Locales', 'en', @$options['languages'])); 150 151 $configuration_file = $FrameworkSetup->getConfigurationFile(); 152 $db_configuration_file = $FrameworkSetup->getDatabaseConfigurationFile(); 153 154 155 if( $FrameworkSetup->canWriteConfigurationFile() && 156 $FrameworkSetup->canWriteDbConfigurationFile()){ 157 $FrameworkSetup->writeConfigurationFile($configuration_file) && 158 $FrameworkSetup->writeDatabaseConfigurationFile($db_configuration_file) && 159 $FrameworkSetup->writeRoutesFile() && 160 $FrameworkSetup->runFrameworkInstaller(); 161 echo "\nYour application has been confirured correctly\n"; 162 echo "\nSee config/config.php and config/database.yml\n"; 163 } 164 165 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |