Adding a basic installer.

This commit is contained in:
Dan Cryer 2013-05-10 15:00:42 +01:00
parent 14f40e9b0f
commit 543290d67f
2 changed files with 47 additions and 0 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
.idea
vendor/
composer.lock
composer.phar
config.php
.DS_Store

46
install.php Normal file
View file

@ -0,0 +1,46 @@
#!/usr/bin/php
<?php
$dbHost = ask('Enter your MySQL host: ');
$dbName = ask('Enter the database name PHPCI should use: ');
$dbUser = ask('Enter your MySQL username: ');
$dbPass = ask('Enter your MySQL password: ');
$cmd = 'mysql -u' . $dbUser . (!empty($dbPass) ? ' -p' . $dbPass : '') . ' -h' . $dbHost . ' -e "CREATE DATABASE IF NOT EXISTS ' . $dbName . '"';
shell_exec($cmd);
file_put_contents('./config.php', "<?php
define('PHPCI_DB_HOST', '{$dbHost}');
b8\Database::setDetails('{$dbName}', '{$dbUser}', '{$dbPass}');
b8\Database::setWriteServers(array('{$dbHost}'));
b8\Database::setReadServers(array('{$dbHost}'));
");
require_once('bootstrap.php');
$gen = new b8\Database\Generator(b8\Database::getConnection(), 'PHPCI', './PHPCI/Model/Base/');
$gen->generate();
print 'INSTALLING: Composer' . PHP_EOL;
file_put_contents('./composerinstaller.php', file_get_contents('https://getcomposer.org/installer'));
shell_exec('php ./composerinstaller.php');
unlink('./composerinstaller.php');
print 'RUNNING: Composer' . PHP_EOL;
shell_exec('./composer.phar install');
function ask($question)
{
print $question . ' ';
$rtn = '';
$fp = fopen('php://stdin', 'r');
$rtn = fgets($fp);
fclose($fp);
return trim($rtn);
}