Skip to content

Instantly share code, notes, and snippets.

@johnny13
Last active December 29, 2015 16:59
Show Gist options
  • Select an option

  • Save johnny13/7700604 to your computer and use it in GitHub Desktop.

Select an option

Save johnny13/7700604 to your computer and use it in GitHub Desktop.
Lithium [ li3 ] PHP Composer InstallerInstall Li3 with composer library for plugins and hui repo in webroot
#!/usr/bin/php
<?php
/*
* -- li3-bootlegger --
* usage: php li3-bootlegger.php myapp
*
* note: run from server webroot. ie /var/www
* then your app will be availabel at http://yourserver.com/myapp
*
* this will setup composer.phar & hui with lithium.
* read more here:
*
* https://github.com/joseym/li3_installer
* http://getcomposer.org
* http://hui.huement.com
*
*/
set_time_limit(0);
error_reporting(E_ALL);
ini_set('memory_limit', '25M');
ini_set('display_errors', true);//Just in case we get some errors, let us know....
date_default_timezone_set('America/Chicago');
/*
* -- SCRIPT OPTIONS--
*/
$modezero = 0; //Part that Downloads Li3 App Framework
$modeone = 0; //Installs Composer & Setups Libraries
$modetwo = 1; //Adds Lithium Library as Submodule via github
$modethree = 0; //Installs hui github repo in webroot
$modefour = 1; //Web File Uploader
$verbose = "false";
function outheader($text){
echo "\n";
echo "-------[ ";
echo $text;
echo " ]-------";
echo "\n"; echo "\n";
}
function final_speech(){
echo "------------ FINAL TODO --------------"."\n";
echo "There are still a few things to do!"; echo "\n";
echo "View the README for more details.";
echo "\n"."\n"."------------ SESSION --------------"."\n";
echo "If you ran modethree your session is autostarting. but you will need to manually \n set the path and web urls in /app/config/bootstrap/session.php"
echo "Run this to check php.ini SESSION auto_start"; echo "\n"; echo "\n";
$cmds = "php -i | grep 'session.auto_start'";
print_r($cmds);
echo "\n"; echo "\n"; echo "else add session_start(); in bootstrap.php";
echo "\n"."\n"." ------------"."\n";
}
if(!isset($argv[1])){
outheader("ERROR");
echo "FORMAT: li3-installer.php RelativeDIR"."\n";
exit;
} else {
$targetdir = $argv[1];
}
$dir = getcwd();
$li3_directory = $dir."/".$targetdir;
$breaker = "\n"."\n"."------------ ".$targetdir." --------------"."\n"."\n";
outheader("Mixing Li3 Bootleg");
if($modezero == 1){
$gitCMD = "git clone https://github.com/UnionOfRAD/framework.git"." ".$targetdir;
outheader("git li3 framework");
echo "\n".$gitCMD."\n";
system($gitCMD, $retval);
print_r($retval); echo $breaker;
$gitFix = "chmod -R 0777 ".$li3_directory."/app/resources";
outheader("Resources Directory Fix");
print_r($gitFix);
system($gitFix, $retval);
print_r($retval); echo $breaker; sleep(1);
}
if($modeone == 1){
if($verbose != "false"){
echo "\n";
echo "http://askubuntu.com/questions/116960/global-installation-of-composer-manual";
echo "\n";
}
$ComposerFile = "wget http://huement.s3.amazonaws.com/code/composer.json"." -O ".$li3_directory."/composer.json";
outheader("Composer Setup");
print_r($ComposerFile);
system($ComposerFile, $retval);
print_r($retval); echo "\n";
$ComposerCmd = "cd ".$li3_directory." && composer update && composer install"."\n";
system($ComposerCmd, $retval);
print_r($retval); echo $breaker; sleep(1);
}
if($modetwo == 1){
if($verbose != "false"){
echo "\n";
echo "Requires the Git Command Line Module."."\n";
echo "sudo apt-get install git";
echo "\n";
}
$gitFix = "cd ".$li3_directory." && git submodule init && git submodule update";
outheader("Lithium Libraries Submodule");
print_r($gitFix);
system($gitFix, $retval);
print_r($retval); echo $breaker; sleep(1);
}
if($modethree == 1){
if($verbose != "false"){
echo "\n";
echo "Improves built in BootStrap UI."."\n";
echo "\n";
}
$gitFix = "cd ".$li3_directory."/app/webroot && git clone https://github.com/johnny13/hui";
outheader("hui framework");
print_r($gitFix);
system($gitFix, $retval);
print_r($retval); echo $breaker; sleep(1);
if($verbose != "false"){
echo "\n";
echo "Improves Lithium Libraries."."\n";
echo "\n";
}
$gitFix = "cd ".$li3_directory."/libraries && wget http://dev.huement.com/li3-bootleg-libraries/archive.zip && unzip archive.zip";
outheader("hui additional libraries");
print_r($gitFix);
system($gitFix, $retval);
print_r($retval); echo $breaker; sleep(1);
system("rm ".$li3_directory."/libraries/archive.zip");
$sessionfile = "https://gist.githubusercontent.com/johnny13/3bc72325f7bd059f69a4/raw/aebd2b41dd296d6f02364f5f7985e31d30e0eef9/session.php";
$gitFix = "wget ".$sessionfile." && mv ./session.php ".$li3_directory."/app/config/bootstrap/session.php && chmod 777 ".$li3_directory."/app/config/bootstrap/session.php";
outheader("hui session fix framework");
print_r($gitFix);
system($gitFix, $retval);
print_r($retval); echo $breaker; sleep(1);
}
if($modefour == 1){
if($verbose != "false"){
echo "\n";
echo "Simple File Upload Setup."."\n";
echo "\n";
}
$gitFix = "cd ".$li3_directory."/app/webroot && wget http://huement.s3.amazonaws.com/code/uploads.zip && unzip ./uploads.zip";
outheader("hui framework");
print_r($gitFix);
system($gitFix, $retval);
system("rm ".$li3_directory."/app/webroot/uploads.zip");
print_r($retval); echo $breaker; sleep(1);
}
//Uploads Directory
//http://huement.s3.amazonaws.com/code/uploads.zip
echo "\n";
outheader("Finished!");
outheader($li3_directory);
echo "\n";
final_speech();
echo "\n";
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment