-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.txt
185 lines (125 loc) · 4.29 KB
/
doc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
KEYPHP DOCUMENTATION
1. SETUP
2. LIBRARIES
3. APPLICATION DECLARATION
4. EXAMPLES
------------ 1. SETUP ------------
to setup a KeyPHP environnement, you need
- the latest version of php
- an empty directory
- access to git
Download the latest Release:
https://github.com/PYLOTT/KeyPHP/releases
unzip the file in a folder
and here you go
to test your installation, type
$ php ENV.php
you should see
Hello World!
---------- 2. LIBRARIES ----------
to import libraries, download the archive file
related to it and extract it. Take the folder
named with the name of your library and copy it
into the "libraries" folder.
example :
we want to install a library called foo
there is foo.zip
we unzip the file
now we get a directory called foo
we copy this directory into the "libraries" fd
now we have our library imported into the folder
NOTE: if the library has a git, you can extract the
lib directly in the folder with a "git clone".
WARNING: libraries in KeyPHP are made a certain way.
They must include:
- a file that require every classes (you are free
to make every classes inside this file but it's
preferred to have one file for each class in an
other folder) example: foo.php
- a file containing every infos on the library called
infos.ini ; this file will be loaded with all classes
and will be stored in a "library object" depending on
the way you import the library.
you can import libraries with several methods.
you can use
import(<your library name>);
or
$<your library name> = PHPLibraryImport(<your library name>);
--- 3. APPLICATION DECLARATION ---
to declare your application, there are several methods
preferred method:
- go into the /conf/ folder
- open appSettings.ini file
- go to [AppInfosHolder]
- replace every variables values with your chosen ones
second method:
go to the application.php file
and change infos in this class
class myApp extends PHPWebAppInfosHolder
by replacing the following variables with yours
{
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";
}
the main class is by default main but you can use an other name
but if so, you need to change your main class file in consequence
the name of the main class file is related to its class.
you need to change both in order to make the application work.
your main class is a class extends of KEYPHPAPPLICATION class
which contains 3 functions that are triggered. every functions are
optional since they are declared in the KEYPHPAPPLICATION class,
but they return true by default and do nothing.
- onStart() : this function is called on algorithm starting. It's
only triggered once and can stop the program by returning false
- loop() : this function is called in a loop that break when the
function returns false.
- onStop() : this function is called on algorithm ending. It's
only triggered once and can stop the program by returning false
------------ EXAMPLES ------------
here are basic examples that uses basic functions
Hello World :
import("base");
class main extends KEYPHPAPPLICATION
{
public function loop()
{
print "Hello World!";
return false;
}
}
Hello World with std-I/O :
import("base");
import("stdio");
class main extends KEYPHPAPPLICATION
{
public function loop()
{
stdio::cout("Hello World!");
return false;
}
}
Hello World + user input with std-I/O :
import("base");
import("stdio");
class main extends KEYPHPAPPLICATION
{
public function onStart()
{
stdio::cout("Hello World!");
return true;
}
public function loop()
{
stdio::cout("What's your age?");
$this->age = stdio::cin();
return false;
}
public function onStop()
{
stdio::cout("Nice ! your age is ".$this->age);
return true;
}
}