Skip to content

Commit 8653c26

Browse files
author
Louis Bertrand
committed
SYSTEM REWRITE : FIRST RELEASE -> 1.1.0
1 parent f15d434 commit 8653c26

236 files changed

Lines changed: 25621 additions & 121 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ENV.php

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
<?php
22

3-
// PHP ENVIRONEMENT SETUP
3+
define("debug",true);
4+
$debugMask[]="ERROR";
5+
// $debugMask[]="INFOS";
6+
$debugMask[]="WARNS";
47

5-
define("PHPENV_LibrariesDIR", "libraries");
6-
define("PHPENV_LibrariesDatabase", PHPENV_LibrariesDIR."/libraries.ini");
8+
if (debug && in_array("INFOS",$debugMask)) {
9+
print "ENV SETUP\r\n\r\n";
10+
}
711

8-
$libraries = parse_ini_file(PHPENV_LibrariesDatabase,true);
12+
$env_ = json_decode(file_get_contents("env.json"), true);
913

10-
define("yt.pylott.keyphp.base", PHPENV_LibrariesDIR."/".$libraries["libraries"]["yt.pylott.keyphp.base"]);
14+
define("appInfosPath","appInfos.json");
15+
define("environnementPrefix",$env_["EnvOutputPrefix"]);
1116

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

14-
// 1.0.1.BETA feature : #0001 : appSettingsFile
15-
// application datas will come from a .ini file
19+
print environnementPrefix."ENV Name: ".$env_["Name"]."\r\n";
20+
print environnementPrefix."ENV Version: ".$env_["Version"]."\r\n";
21+
print environnementPrefix."ENV Authors: "."\r\n";
22+
print_r($env_["Authors"]);
23+
print environnementPrefix."ENV PackageID: ".$env_["PackageID"]."\r\n";
24+
print "\r\n\r\n";
1625

17-
$GLOBAL_appSettings = parse_ini_file("conf/appSettings.ini", true);
26+
}
1827

19-
// var_dump($GLOBAL_appSettings);
20-
// exit;
28+
$appInfos = json_decode(file_get_contents(appInfosPath));
2129

22-
$GLOBAL_packageID = $GLOBAL_appSettings["AppInfosHolder"]["packageID"];
23-
$GLOBAL_infos = $GLOBAL_appSettings["AppInfosHolder"]["infos"];
24-
$GLOBAL_author = $GLOBAL_appSettings["AppInfosHolder"]["author"];
25-
$GLOBAL_version = $GLOBAL_appSettings["AppInfosHolder"]["version"];
26-
$GLOBAL_mainClass = $GLOBAL_appSettings["AppInfosHolder"]["mainClass"];
27-
28-
// end of 1.0.1.BETA feature : #0001 : appSettingsFile
29-
30-
require_once("application.php");
30+
$autoLoad = require('autoload.php');
31+
if ($autoLoad) {
32+
$application = require('application.php');
33+
} else {
34+
print "\033[0;31mFATAL ERROR: AUTOLOAD FAILED [0X2000]\r\nABORTING\r\n\033[m";
35+
return 1;
36+
}
File renamed without changes.

LISENCE.composer

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Nils Adermann, Jordi Boggiano
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: Download_Library Download_Basic_Libraries
1+
.PHONY: Download_Library Download_Basic_Libraries Update_Basic_Libraries _NOTICE
22
.DEFAULT_GOAL=help
33

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

20+
_NOTICE: ## Downloading a library that is allready in your lib directory will cause overwritting
21+
2022
Download_Library: ## download a library with a URL - call this with the correct parametters according to your library
2123
@echo "$(OK_COLOR)"
2224
curl -o libraries/$(LibraryName).zip '$(LibraryURL)'
@@ -41,17 +43,30 @@ Download_Basic_Libraries: ## download required - or not - basic libraries
4143
@echo "Download Successful$(NO_COLOR)"
4244

4345
Update_Basic_Libraries: ## update required - or not - basic libraries WARNING: YOUR PREVIOUS VERSION WILL BE OVERWRITTEN
44-
@echo "$(OK_COLOR)"
46+
@echo "$(NO_COLOR)"
4547
curl -o libraries/base.zip 'https://raw.githubusercontent.com/PYLOTT/KeyPHP_Basic_Libraries/master/base.zip'
4648
@echo "$(WARN_COLOR)"
4749
rm -r libraries/base/
4850
unzip libraries/base.zip -d libraries/
4951
rm libraries/base.zip
50-
@echo "$(OK_COLOR)"
52+
@echo "$(NO_COLOR)"
5153
curl -o libraries/stdio.zip 'https://raw.githubusercontent.com/PYLOTT/KeyPHP_Basic_Libraries/master/stdio.zip'
5254
@echo "$(WARN_COLOR)"
5355
rm -r libraries/stdio/
5456
unzip libraries/stdio.zip -d libraries/
5557
rm libraries/stdio.zip
56-
@echo "$(OK_COLOR)"
57-
@echo "Updation Successful!!$(NO_COLOR)"
58+
@echo "$(NO_COLOR)"
59+
@echo "Updation Successful!!$(NO_COLOR)"
60+
61+
KeyPHP_Download_Library_FROM_REPO: ## download a library by name from the official repo (WARNING!!! the repo is not made yet)
62+
@echo "$(NO_COLOR)"
63+
curl -o libraries/$(LibraryName).zip 'https://keyphp.pylott.yt/librepo/download?n=$(LibraryName)&v=latest'
64+
@echo "$(WARN_COLOR)"
65+
unzip libraries/$(LibraryName).zip -d libraries/
66+
rm libraries/$(LibraryName).zip
67+
@echo "$(NO_COLOR)"
68+
@echo "Download Successful$(NO_COLOR)"
69+
70+
GET_Libraries_FROM_REPO: ## return a list of every libraries on the repo (WARNING!!! the repo is not made yet)
71+
@echo "$(NO_COLOR)"
72+
curl -o libraries/list.txt 'https://keyphp.pylott.yt/librepo/list.txt'

app/main.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?php
22

33
// in order to import a library,
4-
// call import($libname) function
5-
import("base");
6-
import("stdio");
4+
use STDio\stdio;
75

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

12-
class main extends KEYPHPAPPLICATION
10+
class main extends KeyPHPKernel\KEYPHPAPPLICATION
1311
{
1412

1513
public function loop()

appInfos.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
3+
"appName":"KeyPHP WITH COMPOSER COMPATIBILITY",
4+
"mainClass":"main",
5+
"infos":"A RELEASE VERSION OF KeyPHP WITH COMPOSER COMPATIBILITY",
6+
"authors":
7+
[
8+
"Louis Bertrand <adressepro111@pylott.yt>"
9+
],
10+
"License":"MIT",
11+
"version":"1.1.0",
12+
"packageName":"yt.pylott.keyPHP",
13+
"CompilationTarget":
14+
{
15+
"MACOS":
16+
[
17+
18+
"10.9.*",
19+
"10.10.*",
20+
"10.11.*",
21+
"10.12.*",
22+
"10.13.*",
23+
"10.14.*"
24+
25+
],
26+
"WINDOWS":
27+
[
28+
29+
"7.*",
30+
"8.*",
31+
"10.*"
32+
33+
],
34+
"LINUX":
35+
[
36+
37+
"*"
38+
39+
]
40+
},
41+
"Lang":"EN-UK/US"
42+
43+
}

application.php

Lines changed: 8 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,18 @@
11
<?php
22

3-
/**
4-
* myApp is a generic name for KeyPHP application info holders;
5-
* here you declare your application by defining different variables
6-
* if you choose to declare your app via the constructor method,
7-
* please make sure to erase values of the variables
8-
* and declare theme one by one in the __constructor method calling
9-
* E.G.
10-
* class myApp extendsPHPWebAppInfosHolder
11-
* {
12-
* var $packageID,$infos,$author,$version,$mainClass;
13-
* }
14-
* // and then replace values in the following order
15-
* $myAppInfos = new myApp($packageID,$infos,$author,$version,$mainClass);
16-
*/
17-
class myApp extends PHPWebAppInfosHolder
18-
{
19-
20-
// to declare your app directly with the given variables of the class
21-
// modify those variables to your wish
22-
// var $packageID = "yt.pylott.keyphp.example";
23-
// var $infos = "an example application made using keyphp";
24-
// var $author = "Louis Bertrand <adressepro111@pylott.yt>";
25-
// var $version = "1.0.0.BETA";
26-
// var $mainClass = "main";
27-
28-
/**
29-
* if you want to use the constructor,
30-
* replace the previous variables with those ones
31-
*/
32-
33-
/**appPackageId ex: com.organization.package*/
34-
var $packageID = null;
35-
/**appInfos ex: AI algorithm*/
36-
var $infos = null;
37-
/**appAuthor ex: Leonard Da Vinci*/
38-
var $author = null;
39-
/**appVersion ex: v2763:22:CZA-Z.1.BETA or v1.0*/
40-
var $version = null;
41-
/**mainClass ex: main*/
42-
var $mainClass = null;
43-
44-
// or use construct to
45-
public function __construct($packageID = "",$infos = "",$author = "",$version = "",$mainClass = "") {
46-
if (is_null($this->packageID)) {
47-
$this->packageID = $packageID;
48-
}
49-
if (is_null($this->infos)) {
50-
$this->infos = $infos;
51-
}
52-
if (is_null($this->author)) {
53-
$this->author = $author;
54-
}
55-
if (is_null($this->version)) {
56-
$this->version = $version;
57-
}
58-
if (is_null($this->mainClass)) {
59-
$this->mainClass = $mainClass;
60-
}
61-
}
62-
3+
if (debug && in_array("INFOS",$debugMask)) {
4+
print "APPLICATION SETUP\r\n\r\n";
635
}
646

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

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

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

12+
require "app/".$myAPP->mainClass.".php";
13+
$mainClass = new $myAPP->mainClass;
7614

15+
7716
// ACTUAL EXECUTION
7817

7918

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

autoload.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
if (debug && in_array("INFOS",$debugMask)) {print environnementPrefix."Importing KeyPHP Libraries\r\n";}
4+
5+
if(!is_dir("libraries")){
6+
7+
if (debug && in_array("ERROR", $debugMask)) {
8+
print "\033[0;31mFATAL ERROR: LIBRARIES FOLDER DOESN'T EXIST. [0X2001]\r\n\033[m";
9+
print "\033[0;31m TO REPAIRE, TYPE\r\n\033[m";
10+
print "\e[3mmkdir libraries\r\n";
11+
print "make Download_Basic_Libraries\r\n\033[m";
12+
}
13+
return false;
14+
15+
}
16+
17+
$LibDir = scandir("libraries");
18+
19+
// AUTO LOAD OF KEYPHP LIBRARIES
20+
21+
foreach ($LibDir as $key => $value) {
22+
if ($value != "." && $value != "..") {
23+
if (file_exists("libraries/".$value."/".$value.".php")) {
24+
require "libraries/".$value."/".$value.".php";
25+
if (debug && in_array("INFOS",$debugMask)) {
26+
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
27+
}
28+
} elseif (file_exists("libraries/".$value."/loader.php")) {
29+
require "libraries/".$value."/loader.php";
30+
if (debug && in_array("INFOS",$debugMask)) {
31+
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
32+
}
33+
} else {
34+
if (file_exists("libraries/".$value."/infos.ini")) {
35+
$clibinfos=parse_ini_file("libraries/".$value."/infos.ini",true);
36+
if (isset($clibinfos["infos"]["loaderFileName"])) {
37+
if (file_exists("libraries/".$value."/".$clibinfos["loaderFileName"].".php")) {
38+
require "libraries/".$value."/".$clibinfos["loaderFileName"].".php";
39+
if (debug && in_array("INFOS",$debugMask)) {
40+
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
41+
}
42+
} else {
43+
if (debug && in_array("ERROR", $debugMask)) {
44+
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE\r\n\033[m";
45+
}
46+
}
47+
} else {
48+
if (debug && in_array("ERROR", $debugMask)) {
49+
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE IN INFOS.INI\r\n\033[m";
50+
}
51+
}
52+
} elseif (file_exists("libraries/".$value."/infos.json")) {
53+
$clibinfos=json_decode(file_get_contents("libraries/".$value."/infos.json",true));
54+
if (isset($clibinfos["infos"]["loaderFileName"])) {
55+
if (file_exists("libraries/".$value."/".$clibinfos["loaderFileName"].".php")) {
56+
require "libraries/".$value."/".$clibinfos["loaderFileName"].".php";
57+
if (debug && in_array("INFOS", $debugMask)) {
58+
echo environnementPrefix."\033[0;32mLIBRARY \"".$value."\" LOADING: SUCCESS\r\n\033[m";
59+
}
60+
} else {
61+
if (debug && in_array("ERROR", $debugMask)) {
62+
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE\r\n\033[m";
63+
}}
64+
} else {
65+
if (debug && in_array("ERROR", $debugMask)) {
66+
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING LOADER FILE IN INFOS.JSON\r\n\033[m";
67+
}}
68+
} elseif( !is_dir("libraries/".$value) ) {
69+
70+
// Ignore
71+
72+
} else {
73+
if (debug && in_array("ERROR", $debugMask)) {
74+
print environnementPrefix."\033[0;31mERROR: UNABLE TO LOAD LIBRARY \"".$value."\" MISSING INFOS.INI FILE OR LOADER FILE\r\n\033[m";
75+
}}
76+
}
77+
}
78+
}
79+
80+
// AUTO LOAD OF COMPOSER LIBRARIES
81+
82+
if (file_exists("vendor/autoload.php")) {
83+
$vendorAutoLoad = require "vendor/autoload.php";
84+
} else {
85+
if (debug && in_array("WARNS", $debugMask)) {
86+
echo environnementPrefix."\033[0;33mFile 'vendor/autoload.php' can't be find, Ignoring.\r\n\033[m";
87+
}
88+
}
89+
90+
return true;

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"monolog/monolog": "^1.24"
4+
}
5+
}

0 commit comments

Comments
 (0)