Path to project root * @pPackages Packages to load * */ public function __construct($pRoot, $pPackages){ /* [1] Stores the path =========================================================*/ $this->root = $pRoot; /* [2] Stores the packages =========================================================*/ $this->packages = $pPackages; } public function build(){ /* [1] Builds project's base file structure =========================================================*/ /* (1) Copy from src/files */ echo "(1) Building file structure\n"; shell_exec("cp -r ".__ROOT__."/src/files/* ".$this->root); shell_exec("cp -r ".__ROOT__."/src/files/.htaccess ".$this->root."/.htaccess"); /* [2] Browse each package to load =========================================================*/ echo "(2) Building packages\n"; $count = 1; foreach($this->packages as $package=>$version){ $path = "$package/$version"; echo " ($count) $package:$version\n"; /* (1) Copy package folder if it exists */ if( file_exists(__ROOT__."/src/packages/$path") && is_dir(__ROOT__."/src/packages/$path") && count(scandir(__ROOT__."/src/packages/$path")) > 2 ) shell_exec("cp -r ".__ROOT__."/src/packages/$path ".$this->root."/build/$package"); /* (2) Copy package config if it exists */ if( file_exists(__ROOT__."/src/config/$path") && is_dir(__ROOT__."/src/config/$path") && count(scandir(__ROOT__."/src/config/$path")) > 2 ) shell_exec("cp -r ".__ROOT__."/src/config/$path/* ".$this->root."/config/"); $count++; } echo "(*) Build finished\n"; /* [3] Start stats =========================================================*/ echo "\n\nStatistics:\n"; echo shell_exec("du -hs ".$this->root."/*;"); echo "--\n"; echo shell_exec("du -hs ".$this->root."/;"); } }