<?php
// Define Paths
// create folders
// create files
// load contents in files
// device algorithm to create new feature/component
$projectFolders = array(
array(
"name" => "public",
"id" => "f1",
"parent" => ""
),
array(
"name" => "private",
"id" => "f2",
"parent" => ""
),
array(
"name" => "core",
"id" => "f3",
"parent" => "f2"
),
array(
"name" => "addons",
"id" => "f4",
"parent" => "f2"
),
array(
"name" => "controller",
"id" => "f5",
"parent" => "f3"
),
array(
"name" => "model",
"id" => "f6",
"parent" => "f3"
),
array(
"name" => "view",
"id" => "f7",
"parent" => "f3"
),
array(
"name" => "templates", // there is another templates folder in public folder , for js css etc
"id" => "f8",
"parent" => "f3"
),
array(
"name" => "libraries",
"id" => "f9",
"parent" => "f3"
),
array(
"name" => "helpers",
"id" => "f10",
"parent" => "f3"
),
array(
"name" => "composer",
"id" => "f11",
"parent" => "f3"
),
array(
"name" => "temp",
"id" => "f12",
"parent" => "f2"
),
array(
"name" => "crons",
"id" => "f13",
"parent" => "f2"
),
array(
"name" => "crons",
"id" => "f14",
"parent" => "f2"
),
array(
"name" => "lang",
"id" => "f15",
"parent" => "f2"
),
array(
"name" => "cache",
"id" => "f16",
"parent" => "f2"
),
array(
"name" => "logs",
"id" => "f17",
"parent" => "f2"
),
array(
"name" => "uploads",
"id" => "f18",
"parent" => "f2"
),
array(
"name" => "temp",
"id" => "f19",
"parent" => "f2"
),
array(
"name" => "backups",
"id" => "f20",
"parent" => "f2"
),
array(
"name" => "config", // config files set while driving through online config setup
"id" => "f21",
"parent" => "f3"
),
array(
"name" => "setup", // for driving through online config setup
"id" => "f22",
"parent" => "f3"
),
array(
"name" => "templates", // this is for js css etc, there is another templates folder in private folder
"id" => "f23",
"parent" => "f1"
),
);
$projectFiles = array(// index.html is created for each folders
array(
"name" => "index.php",
"id" => "f1",
"parent"=> "f1"
),
array(
"name" => ".htaccess",
"id" => "f2",
"parent"=> "f1"
),
array(
"name" => "config.php",
"id" => "f3",
"parent"=> "f21"
),
array(
"name" => "bootstrap.php",
"id" => "f4",
"parent"=> "f3"
),
);
//refer https://www.giuseppemaccario.com/how-to-build-a-simple-php-mvc-framework/
$projectFileContents = array(
//"f2" =>
);
//Step 2 : create folders
echo "<h2>Creating Folders</h2>";
$createdFolders = array();
$fullFolderPaths = array();
$createdFolderNo = 0;
foreach($projectFolders as $projectFolderDetails)
{
$folderID = $projectFolderDetails['id'];
$createdFolders[$folderID] = $projectFolderDetails;
$folderParentId = $projectFolderDetails['parent'];
$folderName = $projectFolderDetails['name'];
$folderFullPath = $folderName;
while($folderParentId != "")
{
$folderFullPath = $createdFolders[$folderParentId]['name']."/".$folderFullPath;
$folderParentId = $createdFolders[$folderParentId]['parent'];
}//while(true)
if (!file_exists($folderFullPath))
{
$createdFolderNo++;
echo $createdFolderNo . ". Creating ". $folderFullPath. "<br />";
$fullFolderPaths[$folderID] = $folderFullPath;
mkdir($folderFullPath, 0777, true);
}
}//foreach($projectFolders as $projectFolder)
// Step 3 : Create files
$createdFiles = 0;
echo "<h2>Creating Files</h2>";
foreach($projectFiles as $projectFileDetails)
{
$parentId = $projectFileDetails['parent'];
$fullFilePath = $fullFolderPaths[$parentId] ."/".$projectFileDetails['name'];
$createdFiles++;
echo $createdFiles . ". Creating ". $fullFilePath. "<br />";
file_put_contents($fullFilePath,"");
}//foreach($projectFiles as $projectFileDetails)
?>
|
|