@@ -38,43 +38,32 @@ protected function configure()
3838 protected function execute (InputInterface $ input , OutputInterface $ output )
3939 {
4040 // Gather initial data from the user:
41- $ dbHost = $ this ->ask ('Enter your MySQL host: ' );
42- $ dbName = $ this ->ask ('Enter the database name PHPCI should use: ' );
43- $ dbUser = $ this ->ask ('Enter your MySQL username: ' );
44- $ dbPass = $ this ->ask ('Enter your MySQL password: ' , true );
45- $ ciUrl = $ this ->ask ('Your PHPCI URL (without trailing slash): ' );
46- $ ghId = $ this ->ask ('(Optional) Github Application ID: ' , true );
47- $ ghSecret = $ this ->ask ('(Optional) Github Application Secret: ' , true );
41+ $ conf = array ();
42+ $ conf ['b8 ' ]['database ' ]['servers ' ]['read ' ] = $ this ->ask ('Enter your MySQL host: ' );
43+ $ conf ['b8 ' ]['database ' ]['servers ' ]['write ' ] = $ conf ['b8 ' ]['database ' ]['servers ' ]['read ' ];
44+ $ conf ['b8 ' ]['database ' ]['name ' ] = $ this ->ask ('Enter the database name PHPCI should use: ' );
45+ $ conf ['b8 ' ]['database ' ]['username ' ] = $ this ->ask ('Enter your MySQL username: ' );
46+ $ conf ['b8 ' ]['database ' ]['password ' ] = $ this ->ask ('Enter your MySQL password: ' , true );
47+ $ conf ['phpci ' ]['url ' ] = $ this ->ask ('Your PHPCI URL (without trailing slash): ' );
48+ $ conf ['phpci ' ]['github ' ]['id ' ] = $ this ->ask ('(Optional) Github Application ID: ' , true );
49+ $ conf ['phpci ' ]['github ' ]['secret ' ] = $ this ->ask ('(Optional) Github Application Secret: ' , true );
50+
51+ $ dbUser = $ conf ['b8 ' ]['database ' ]['username ' ];
52+ $ dbPass = $ conf ['b8 ' ]['database ' ]['password ' ];
53+ $ dbHost = $ conf ['b8 ' ]['database ' ]['servers ' ]['write ' ];
54+ $ dbName = $ conf ['b8 ' ]['database ' ]['name ' ];
4855
4956 // Create the database if it doesn't exist:
5057 $ cmd = 'mysql -u ' . $ dbUser . (!empty ($ dbPass ) ? ' -p ' . $ dbPass : '' ) . ' -h ' . $ dbHost .
5158 ' -e "CREATE DATABASE IF NOT EXISTS ' . $ dbName . '" ' ;
5259
5360 shell_exec ($ cmd );
5461
55- $ str = "<?php
62+ $ dumper = new \Symfony \Component \Yaml \Dumper ();
63+ $ yaml = $ dumper ->dump ($ conf );
5664
57- if(!defined('PHPCI_DB_HOST')) {
58- define('PHPCI_DB_HOST', ' {$ dbHost }');
59- }
60-
61- b8\Database::setDetails(' {$ dbName }', ' {$ dbUser }', ' {$ dbPass }');
62- b8\Database::setWriteServers(array(' {$ dbHost }'));
63- b8\Database::setReadServers(array(' {$ dbHost }'));
64-
65- \$config = b8\Config::getInstance();
66- \$config->set('install_url', ' {$ ciUrl }');
67- " ;
68-
69- // Has the user entered Github app details? If so add those to config:
70- if (!empty ($ ghId ) && !empty ($ ghSecret )) {
71- $ str .= PHP_EOL .
72- "\$registry->set('github_app', array('id' => ' {$ ghId }', 'secret' => ' {$ ghSecret }')); " .
73- PHP_EOL ;
74- }
65+ file_put_contents (PHPCI_DIR . 'PHPCI/config.yml ' , $ yaml );
7566
76- // Write the config file and then re-bootstrap:
77- file_put_contents (PHPCI_DIR . 'config.php ' , $ str );
7867 require (PHPCI_DIR . 'bootstrap.php ' );
7968
8069 // Update the database:
0 commit comments