Skip to content

Commit 736b324

Browse files
author
Louis Bertrand
committed
Release Master V1.0.1.BETA
1 parent c932672 commit 736b324

7 files changed

Lines changed: 151 additions & 29 deletions

File tree

ENV.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,20 @@
1111

1212
require_once(constant("yt.pylott.keyphp.base"));
1313

14+
// 1.0.1.BETA feature : #0001 : appSettingsFile
15+
// application datas will come from a .ini file
16+
17+
$GLOBAL_appSettings = parse_ini_file("conf/appSettings.ini", true);
18+
19+
// var_dump($GLOBAL_appSettings);
20+
// exit;
21+
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+
1430
require_once("application.php");

app/main.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ class main extends KEYPHPAPPLICATION
1414

1515
public function loop()
1616
{
17+
18+
// // OverKill method for std io that reads and prints user prompted value
19+
// $stdio = new stdio;
20+
// $stdin = $stdio->openstdin();
21+
// $val = $stdio->ccin();
22+
// $stdout = $stdio->openstdout();
23+
// $stdio->ccout($val);
24+
// $stdio->closestdin($stdin);
25+
// $stdio->closestdout($stdout);
26+
27+
// // basic method for std io that reads and prints user prompted value
28+
// stdio::cout(stdio::cin());
29+
1730
stdio::cout("Hello World!");
1831
new bis;
1932
return false;

application.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,30 @@
1616
*/
1717
class myApp extends PHPWebAppInfosHolder
1818
{
19-
19+
20+
// to declare your app directly with the given variables of the class
2021
// modify those variables to your wish
21-
var $packageID = "yt.pylott.keyphp.example";
22-
var $infos = "an example application made using keyphp";
23-
var $author = "Louis Bertrand <adressepro111@pylott.yt>";
24-
var $version = "1.0.0.BETA";
25-
var $mainClass = "main";
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";
2627

2728
/**
2829
* if you want to use the constructor,
29-
* replace the previous variables with thoose ones
30+
* replace the previous variables with those ones
3031
*/
3132

32-
// var $packageID;
33-
// var $infos;
34-
// var $author;
35-
// var $version;
36-
// var $mainClass;
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;
3743

3844
// or use construct to
3945
public function __construct($packageID = "",$infos = "",$author = "",$version = "",$mainClass = "") {
@@ -55,12 +61,11 @@ public function __construct($packageID = "",$infos = "",$author = "",$version =
5561
}
5662

5763
}
58-
64+
5965
// here the application is declared
6066
// you can declare your app with construct method or directly into the class
6167
// previously declared
62-
// in future releases, a more elegant way would be appricieated
63-
$myAppInfos = new myApp();
68+
$myAppInfos = new myApp($GLOBAL_packageID,$GLOBAL_infos,$GLOBAL_author,$GLOBAL_version,$GLOBAL_mainClass);
6469

6570
// we require the main class
6671
require_once("app/".$myAppInfos->mainClass.".php");
@@ -94,3 +99,4 @@ public function __construct($packageID = "",$infos = "",$author = "",$version =
9499
print("Program ended with return value ".$onStopResponse."\r\n");
95100
exit;
96101
}
102+

conf/appSettings.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[AppInfosHolder]
2+
packageID=appPackageId ; appPackageId ex: com.organization.package
3+
infos=appInfos ; appInfos ex: AI algorithm
4+
author=appAuthor ; appAuthor ex: Leonard Da Vinci
5+
version=appVersion ; appVersion ex: v2763:22:CZA-Z.1.BETA or v1.0
6+
mainClass=main ; mainClass ex: main

doc.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ to setup a KeyPHP environnement, you need
1616
first you need to clone the git into your folder
1717

1818
$ cd <your folder>
19-
$ git clone git:github.com/PYLOTT/KeyPHP.git
19+
$ git clone git://github.com/PYLOTT/KeyPHP.git
2020

2121
and here you go
2222

@@ -54,8 +54,10 @@ lib directly in the folder with a "git clone".
5454
WARNING: libraries in KeyPHP are made a certain way.
5555
They must include:
5656

57-
- a file that require every classes
58-
example: foo.php
57+
- a file that require every classes (you are free
58+
to make every classes inside this file but it's
59+
preferred to have one file for each class in an
60+
other folder) example: foo.php
5961
- a file containing every infos on the library called
6062
infos.ini ; this file will be loaded with all classes
6163
and will be stored in a "library object" depending on
@@ -73,7 +75,17 @@ or
7375

7476
--- 3. APPLICATION DECLARATION ---
7577

76-
to declare your application go to the application.php file
78+
to declare your application, there are several methods
79+
80+
preferred method:
81+
82+
- go into the /conf/ folder
83+
- open appSettings.ini file
84+
- go to [AppInfosHolder]
85+
- replace every variables values with your chosen ones
86+
87+
second method:
88+
go to the application.php file
7789
and change infos in this class
7890

7991
class myApp extends PHPWebAppInfosHolder

libraries/base/links/KEYPHPAPPLICATION.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function loop()
4343
public function onStop()
4444
{
4545

46-
return false;
46+
return true;
4747

4848
}
4949

libraries/stdio/links/stdio.php

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,85 @@ class stdio
1616
*/
1717
var $stdout;
1818

19+
/**
20+
* openstdin
21+
*
22+
* open stdin stream file
23+
*
24+
* @usage
25+
* $stdio = new stdio;
26+
* $stdin = $stdio->openstdin();
27+
*
28+
* @return resource|false
29+
*/
1930
public function openstdin() {
2031
$this->stdin = fopen('php://stdin', 'r');
32+
return $this->stdin;
2133
}
2234

35+
36+
/**
37+
* openstdout
38+
*
39+
* open stdout stream file
40+
*
41+
* @usage
42+
* $stdio = new stdio;
43+
* $stdout = $stdio->openstdout();
44+
*
45+
* @return resource|false
46+
*/
2347
public function openstdout() {
2448
$this->stdout = fopen('php://stdout', 'w');
49+
return $this->stdin;
2550
}
2651

27-
public function closestdin() {
52+
/**
53+
* closestdin
54+
*
55+
* close stdin stream file
56+
*
57+
* @usage
58+
* $stdio = new stdio;
59+
* $stdin = $stdio->openstdin();
60+
* $stdio->closestdin($stdin);
61+
*
62+
* @return true
63+
*/
64+
public function closestdin(&$stdin) {
2865
$this->stdin = null;
66+
$stdin = null;
67+
return true;
2968
}
3069

31-
public function closestdout() {
70+
/**
71+
* closestdout
72+
*
73+
* close stdout stream file
74+
*
75+
* @usage
76+
* $stdio = new stdio;
77+
* $stdout = $stdio->openstdout();
78+
* $stdio->closestdout($stdout);
79+
*
80+
* @return true
81+
*/
82+
public function closestdout(&$stdout) {
3283
$this->stdout = null;
84+
$stdout = null;
85+
return true;
3386
}
3487

3588
/**
3689
* cin() function
3790
*
3891
* cin is a function that reads line from stdin
3992
*
40-
* @return mixed
41-
**/
93+
* @usage
94+
* $someVar = stdio::cin();
95+
*
96+
* @return string
97+
*/
4298
public function cin()
4399
{
44100

@@ -50,9 +106,14 @@ public function cin()
50106
* ccin() function
51107
*
52108
* cin is a function that reads line from stdin
109+
*
110+
* @usage
111+
* $stdio = new stdio;
112+
* $stdin = $stdio->openstdin();
113+
* $someVar = $stdio->ccin();
53114
*
54-
* @return mixed
55-
**/
115+
* @return string
116+
*/
56117
public function ccin()
57118
{
58119

@@ -64,9 +125,14 @@ public function ccin()
64125
* cout() function
65126
*
66127
* cout is a function that write line into stdout
67-
*
128+
*
129+
* @usage
130+
* $stdio = new stdio;
131+
* $stdout = $stdio->openstdout();
132+
* $stdio->ccout("some string");
133+
*
68134
* @return int|false
69-
**/
135+
*/
70136
public function ccout($string)
71137
{
72138

@@ -79,8 +145,11 @@ public function ccout($string)
79145
*
80146
* cout is a function that write line into stdout
81147
*
148+
* @usage
149+
* stdio::cout("some string");
150+
*
82151
* @return int|false
83-
**/
152+
*/
84153
public function cout($string)
85154
{
86155

0 commit comments

Comments
 (0)