Skip to content

Commit

Permalink
SYSTEM REWRITE : FIRST RELEASE -> 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Bertrand committed Jul 27, 2019
1 parent f15d434 commit 8653c26
Show file tree
Hide file tree
Showing 236 changed files with 25,621 additions and 121 deletions.
46 changes: 26 additions & 20 deletions ENV.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<?php

// PHP ENVIRONEMENT SETUP
define("debug",true);
$debugMask[]="ERROR";
// $debugMask[]="INFOS";
$debugMask[]="WARNS";

define("PHPENV_LibrariesDIR", "libraries");
define("PHPENV_LibrariesDatabase", PHPENV_LibrariesDIR."/libraries.ini");
if (debug && in_array("INFOS",$debugMask)) {
print "ENV SETUP\r\n\r\n";
}

$libraries = parse_ini_file(PHPENV_LibrariesDatabase,true);
$env_ = json_decode(file_get_contents("env.json"), true);

define("yt.pylott.keyphp.base", PHPENV_LibrariesDIR."/".$libraries["libraries"]["yt.pylott.keyphp.base"]);
define("appInfosPath","appInfos.json");
define("environnementPrefix",$env_["EnvOutputPrefix"]);

require_once(constant("yt.pylott.keyphp.base"));
if (debug && in_array("INFOS",$debugMask)) {

// 1.0.1.BETA feature : #0001 : appSettingsFile
// application datas will come from a .ini file
print environnementPrefix."ENV Name: ".$env_["Name"]."\r\n";
print environnementPrefix."ENV Version: ".$env_["Version"]."\r\n";
print environnementPrefix."ENV Authors: "."\r\n";
print_r($env_["Authors"]);
print environnementPrefix."ENV PackageID: ".$env_["PackageID"]."\r\n";
print "\r\n\r\n";

$GLOBAL_appSettings = parse_ini_file("conf/appSettings.ini", true);
}

// var_dump($GLOBAL_appSettings);
// exit;
$appInfos = json_decode(file_get_contents(appInfosPath));

$GLOBAL_packageID = $GLOBAL_appSettings["AppInfosHolder"]["packageID"];
$GLOBAL_infos = $GLOBAL_appSettings["AppInfosHolder"]["infos"];
$GLOBAL_author = $GLOBAL_appSettings["AppInfosHolder"]["author"];
$GLOBAL_version = $GLOBAL_appSettings["AppInfosHolder"]["version"];
$GLOBAL_mainClass = $GLOBAL_appSettings["AppInfosHolder"]["mainClass"];

// end of 1.0.1.BETA feature : #0001 : appSettingsFile

require_once("application.php");
$autoLoad = require('autoload.php');
if ($autoLoad) {
$application = require('application.php');
} else {
print "\033[0;31mFATAL ERROR: AUTOLOAD FAILED [0X2000]\r\nABORTING\r\n\033[m";
return 1;
}
File renamed without changes.
19 changes: 19 additions & 0 deletions LISENCE.composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) Nils Adermann, Jordi Boggiano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: Download_Library Download_Basic_Libraries
.PHONY: Download_Library Download_Basic_Libraries Update_Basic_Libraries _NOTICE
.DEFAULT_GOAL=help

LibraryURL=https://raw.githubusercontent.com/PYLOTT/KeyPHP_Basic_Libraries/master/base.zip
Expand All @@ -17,6 +17,8 @@ help:
@awk 'BEGIN {FS = ":.*##"; } /^[a-zA-Z_-]+:.*?##/ { printf "$(PRIMARY_COLOR)%-10s$(NO_COLOR) %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | sort
@echo "\n"

_NOTICE: ## Downloading a library that is allready in your lib directory will cause overwritting

Download_Library: ## download a library with a URL - call this with the correct parametters according to your library
@echo "$(OK_COLOR)"
curl -o libraries/$(LibraryName).zip '$(LibraryURL)'
Expand All @@ -41,17 +43,30 @@ Download_Basic_Libraries: ## download required - or not - basic libraries
@echo "Download Successful$(NO_COLOR)"

Update_Basic_Libraries: ## update required - or not - basic libraries WARNING: YOUR PREVIOUS VERSION WILL BE OVERWRITTEN
@echo "$(OK_COLOR)"
@echo "$(NO_COLOR)"
curl -o libraries/base.zip 'https://raw.githubusercontent.com/PYLOTT/KeyPHP_Basic_Libraries/master/base.zip'
@echo "$(WARN_COLOR)"
rm -r libraries/base/
unzip libraries/base.zip -d libraries/
rm libraries/base.zip
@echo "$(OK_COLOR)"
@echo "$(NO_COLOR)"
curl -o libraries/stdio.zip 'https://raw.githubusercontent.com/PYLOTT/KeyPHP_Basic_Libraries/master/stdio.zip'
@echo "$(WARN_COLOR)"
rm -r libraries/stdio/
unzip libraries/stdio.zip -d libraries/
rm libraries/stdio.zip
@echo "$(OK_COLOR)"
@echo "Updation Successful!!$(NO_COLOR)"
@echo "$(NO_COLOR)"
@echo "Updation Successful!!$(NO_COLOR)"

KeyPHP_Download_Library_FROM_REPO: ## download a library by name from the official repo (WARNING!!! the repo is not made yet)
@echo "$(NO_COLOR)"
curl -o libraries/$(LibraryName).zip 'https://keyphp.pylott.yt/librepo/download?n=$(LibraryName)&v=latest'
@echo "$(WARN_COLOR)"
unzip libraries/$(LibraryName).zip -d libraries/
rm libraries/$(LibraryName).zip
@echo "$(NO_COLOR)"
@echo "Download Successful$(NO_COLOR)"

GET_Libraries_FROM_REPO: ## return a list of every libraries on the repo (WARNING!!! the repo is not made yet)
@echo "$(NO_COLOR)"
curl -o libraries/list.txt 'https://keyphp.pylott.yt/librepo/list.txt'
6 changes: 2 additions & 4 deletions app/main.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php

// in order to import a library,
// call import($libname) function
import("base");
import("stdio");
use STDio\stdio;

// in order to import a custom class
// call require_once $file function
require_once "bis.php";

class main extends KEYPHPAPPLICATION
class main extends KeyPHPKernel\KEYPHPAPPLICATION
{

public function loop()
Expand Down
43 changes: 43 additions & 0 deletions appInfos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{

"appName":"KeyPHP WITH COMPOSER COMPATIBILITY",
"mainClass":"main",
"infos":"A RELEASE VERSION OF KeyPHP WITH COMPOSER COMPATIBILITY",
"authors":
[
"Louis Bertrand <adressepro111@pylott.yt>"
],
"License":"MIT",
"version":"1.1.0",
"packageName":"yt.pylott.keyPHP",
"CompilationTarget":
{
"MACOS":
[

"10.9.*",
"10.10.*",
"10.11.*",
"10.12.*",
"10.13.*",
"10.14.*"

],
"WINDOWS":
[

"7.*",
"8.*",
"10.*"

],
"LINUX":
[

"*"

]
},
"Lang":"EN-UK/US"

}
78 changes: 8 additions & 70 deletions application.php
Original file line number Diff line number Diff line change
@@ -1,79 +1,18 @@
<?php

/**
* myApp is a generic name for KeyPHP application info holders;
* here you declare your application by defining different variables
* if you choose to declare your app via the constructor method,
* please make sure to erase values of the variables
* and declare theme one by one in the __constructor method calling
* E.G.
* class myApp extendsPHPWebAppInfosHolder
* {
* var $packageID,$infos,$author,$version,$mainClass;
* }
* // and then replace values in the following order
* $myAppInfos = new myApp($packageID,$infos,$author,$version,$mainClass);
*/
class myApp extends PHPWebAppInfosHolder
{

// to declare your app directly with the given variables of the class
// modify those variables to your wish
// var $packageID = "yt.pylott.keyphp.example";
// var $infos = "an example application made using keyphp";
// var $author = "Louis Bertrand <adressepro111@pylott.yt>";
// var $version = "1.0.0.BETA";
// var $mainClass = "main";

/**
* if you want to use the constructor,
* replace the previous variables with those ones
*/

/**appPackageId ex: com.organization.package*/
var $packageID = null;
/**appInfos ex: AI algorithm*/
var $infos = null;
/**appAuthor ex: Leonard Da Vinci*/
var $author = null;
/**appVersion ex: v2763:22:CZA-Z.1.BETA or v1.0*/
var $version = null;
/**mainClass ex: main*/
var $mainClass = null;

// or use construct to
public function __construct($packageID = "",$infos = "",$author = "",$version = "",$mainClass = "") {
if (is_null($this->packageID)) {
$this->packageID = $packageID;
}
if (is_null($this->infos)) {
$this->infos = $infos;
}
if (is_null($this->author)) {
$this->author = $author;
}
if (is_null($this->version)) {
$this->version = $version;
}
if (is_null($this->mainClass)) {
$this->mainClass = $mainClass;
}
}

if (debug && in_array("INFOS",$debugMask)) {
print "APPLICATION SETUP\r\n\r\n";
}

// here the application is declared
// you can declare your app with construct method or directly into the class
// previously declared
$myAppInfos = new myApp($GLOBAL_packageID,$GLOBAL_infos,$GLOBAL_author,$GLOBAL_version,$GLOBAL_mainClass);
$myApp_Json = json_decode(file_get_contents("appInfos.json"),true);

// we require the main class
require_once("app/".$myAppInfos->mainClass.".php");

// we declare your main Class
$mainClass = new $myAppInfos->mainClass;
$myAPP = new KeyPHPKernel\PHPWebAppInfosHolder($myApp_Json["packageName"],$myApp_Json["infos"],$myApp_Json["authors"],$myApp_Json["version"],$myApp_Json["mainClass"]);

require "app/".$myAPP->mainClass.".php";
$mainClass = new $myAPP->mainClass;


// ACTUAL EXECUTION


Expand All @@ -98,5 +37,4 @@ public function __construct($packageID = "",$infos = "",$author = "",$version =
if(!$onStopResponse){
print("Program ended with return value ".$onStopResponse."\r\n");
exit;
}

}
90 changes: 90 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

if (debug && in_array("INFOS",$debugMask)) {print environnementPrefix."Importing KeyPHP Libraries\r\n";}

if(!is_dir("libraries")){

if (debug && in_array("ERROR", $debugMask)) {
print "\033[0;31mFATAL ERROR: LIBRARIES FOLDER DOESN'T EXIST. [0X2001]\r\n\033[m";
print "\033[0;31m TO REPAIRE, TYPE\r\n\033[m";
print "\e[3mmkdir libraries\r\n";
print "make Download_Basic_Libraries\r\n\033[m";
}
return false;

}

$LibDir = scandir("libraries");

// AUTO LOAD OF KEYPHP LIBRARIES

foreach ($LibDir as $key => $value) {
if ($value != "." && $value != "..") {
if (file_exists("libraries/".$value."/".$value.".php")) {
require "libraries/".$value."/".$value.".php";
if (debug && in_array("INFOS",$debugMask)) {
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
}
} elseif (file_exists("libraries/".$value."/loader.php")) {
require "libraries/".$value."/loader.php";
if (debug && in_array("INFOS",$debugMask)) {
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
}
} else {
if (file_exists("libraries/".$value."/infos.ini")) {
$clibinfos=parse_ini_file("libraries/".$value."/infos.ini",true);
if (isset($clibinfos["infos"]["loaderFileName"])) {
if (file_exists("libraries/".$value."/".$clibinfos["loaderFileName"].".php")) {
require "libraries/".$value."/".$clibinfos["loaderFileName"].".php";
if (debug && in_array("INFOS",$debugMask)) {
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
}
} else {
if (debug && in_array("ERROR", $debugMask)) {
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE\r\n\033[m";
}
}
} else {
if (debug && in_array("ERROR", $debugMask)) {
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE IN INFOS.INI\r\n\033[m";
}
}
} elseif (file_exists("libraries/".$value."/infos.json")) {
$clibinfos=json_decode(file_get_contents("libraries/".$value."/infos.json",true));
if (isset($clibinfos["infos"]["loaderFileName"])) {
if (file_exists("libraries/".$value."/".$clibinfos["loaderFileName"].".php")) {
require "libraries/".$value."/".$clibinfos["loaderFileName"].".php";
if (debug && in_array("INFOS", $debugMask)) {
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
}
} else {
if (debug && in_array("ERROR", $debugMask)) {
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE\r\n\033[m";
}}
} else {
if (debug && in_array("ERROR", $debugMask)) {
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE IN INFOS.JSON\r\n\033[m";
}}
} elseif( !is_dir("libraries/".$value) ) {

// Ignore

} else {
if (debug && in_array("ERROR", $debugMask)) {
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING INFOS.INI FILE OR LOADER FILE\r\n\033[m";
}}
}
}
}

// AUTO LOAD OF COMPOSER LIBRARIES

if (file_exists("vendor/autoload.php")) {
$vendorAutoLoad = require "vendor/autoload.php";
} else {
if (debug && in_array("WARNS", $debugMask)) {
echo environnementPrefix."\033[0;33mFile 'vendor/autoload.php' can't be find, Ignoring.\r\n\033[m";
}
}

return true;
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"monolog/monolog": "^1.24"
}
}
Loading

0 comments on commit 8653c26

Please sign in to comment.