-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfiguration.html
635 lines (527 loc) · 27.6 KB
/
configuration.html
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ness PHP Framework | Docs</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="assets/fnt-aw/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!--Load highlightjs package -->
<link rel="stylesheet" href="assets/js/highlightjs/styles/vs2015.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar">
<div id="sidebar-header" class="text-center">
<br>
<a href="index.html" id="logo-area-link">
<img src="assets/img/nessphp_bordered.png" alt="Ness PHP Documentation" width="70%"/>
<h3>Ness PHP</h3>
<h4>Documentation</h4>
</a>
<a href="index.html" class="btn btn-light btn-sm" style="width: 100%;">
<i class="fa fa-angle-left" aria-hidden="true"></i> Back
</a>
</div>
<br>
<!--Load LATER-->
<div id="sidebar-loader" class="sidebar-contents">
</div>
</nav>
<div id="content">
<!--Nabvar:start-->
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<button id="sidebarCollapse" class="btn-circle">
<i class="fa fa-bars" aria-hidden="true"></i>
</button>
<ul class="nav navbar-nav">
<li class="nav-item">
<a href="index.html" class="navbar-text-header">
Ness PHP Framework
</a>
</li>
</ul>
<button class="btn-circle d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#headernav-links" aria-controls="headernav-links" aria-expanded="false" aria-label="Toggle Menu">
<i class="fa fa-ellipsis-v" aria-hidden="true"></i>
</button>
<div class="collapse navbar-collapse" id="headernav-links">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link " href="https://nessphp.github.io/">
<i class="fa fa-terminal" aria-hidden="true"></i>
Ness PHP
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="https://github.com/nessphp/application">
<i class="fa fa-github" aria-hidden="true"></i>
GitHub
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="support.html">
<i class="fa fa-heart" aria-hidden="true"></i>
Support
</a>
</li>
</ul>
</div>
</div>
</nav>
<!--Nabvar:end-->
<!-- ========================content:start======================== -->
<div id="holder">
<span class="pageheader">Ness PHP Project Configuration</span>
<br>
<div class="row">
<div class="col-lg-8">
<ul class="hash-toc">
<li>Contents
<ul>
<li><a href="#about">About Configuration</a></li>
<li><a href="#file">Configuration Files</a></li>
<li><a href="#example">Example app_config.php file</a></li>
<li><a href="#register">Application Register Method</a></li>
<li><a href="#methods">Class Methods</a></li>
<li><a href="#maintenance">Enable & Design Maintenance Mode</a></li>
</ul>
</li>
</ul>
</div>
<!--Required Namespace -->
<div class="col-lg-4">
<div class="card bg-dark text-white">
<div class="card-header">Required Namespace</div>
<div class="card-body" >
<ul class="tree">
<li style="color:#28A745;">Ness
<ul>
<li style="color:#fff;">Configuration
<!-- <ul><li>Library</li></ul> -->
</li>
</ul>
</li>
</ul>
<hr>
<span><small>You can include this library to your code file by typing the below code;</small></span>
<br><br>
<span style="color:#3490CF;">use</span>
<span style="color:#28A745;">Ness</span>\Configuration
</div>
</div>
</div>
<!--end: Required Namespace -->
</div>
<br><br>
<!--start: topic-->
<h4 id="about">About Configuration <small><a href="#content">#top</a></small></h4>
<p>
Ness PHP controls all system configurations from one point. This will help you manage your configurations easily and quickly. You can manage all configurations from one point and start as quickly as possible to write the main logic of your project and get rid of unneccesary configurations. Ness PHP also supports multi-config files, write configuration files as your needs and switch between them according your needs.
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="file">Configuration File <small><a href="#content">#top</a></small></h4>
<p>
While a request made to Ness PHP, the framework initially loads the configuration file which is app_config.php by default. You can manage all Url security, app description and title or global variable definitions here.In next topic you can see a sample configuration file which is created by default installation of the framework. Please keep reading the documentation for understanding all basics for the configuration file.
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="example">Example Configuration File <small><a href="#content">#top</a></small></h4>
<p>
Default app_config.php content and the basic changes you need to made in your installation;
<br>
<pre><code class="php">
<?php
/**
* Ness PHP Framework.
* A solid php framework for fast and secure web applications.
*
* @author Sinan SALIH
* @license MIT License
* @copyright Copyright (C) 2018-2019 Sinan SALIH
*/
use Ness\Configuration;
/*
* === [Environment Configuration ] ===
* This configuration is used to set the
* development environment for your project.
* You can set 2 types of environments;
* "development" OR "publish"
*/
Configuration::setEnvironment('development');
/*
* === [Application Folder ] ===
* This configuration is generally for security.
* If you need to change the folder name of your
* application you must set it here.
*/
Configuration::setApplicationFolder('Application');
/*
* === [Application Resource Files ] ===
* This function is used to set the
* path of the resource.xml file which is used
* to store static values for your projects(ex; strings, image paths etc)
* Note; the core app location ('Application' by default) is excluded from the value.
*/
Configuration::setResourceFile('Resources.xml');
/*
* === [Application URL ] ===
* This configuration is used to set your
* web sites url. For example if you create a
* application that will be run in root set url to: "http://www.examplesite.com/"
* If your application will be a sub module/application of other application set it like:
* "http://www.examplesite.com/my_module".
*/
Configuration::setApplicationUrl('http://localhost/nessphp');
/*
* === [Is Application Root ] ===
* If your application's url is not accessable by "www.siteexample.com"
* set this false.
*/
Configuration::setRoot(false);
/*
* === [ Application Name ] ===
* This configuration is used to set name of your application.
*/
Configuration::setTitle('Hello World');
/*
* === [ Application Version ] ===
* This configuration is used to set version number of your application.
*/
Configuration::setVersion('1.0.0');
/*
* === [ Application Description ] ===
* This configuration is used to set description of your application.
*/
Configuration::setDescription('Ness PHP is a solid web framework for fast and secure web applications.');
/*
* === [ Application Maintenance Mode ] ===
* This configuration is used to set maintenance mode of your application.
* if Maintenance Mode is enabled user will see a message on screen like
* 'Under Maintenance'
*/
Configuration::enableMaintenance(false);
/**
* === [ Application Url Protection ] ===
* Protect your website from unwanted parameters, You can enable
* this feature for preventing visit with unwanted parameters
* supplied in array below.
*/
Configuration::setUrlProtected(false);
Configuration::UnwantedParameters(array("'"));
/**---------------------------------------------------------*/
/** Application Class */
/**---------------------------------------------------------*/
class Application
{
/**
* This method is called when your application is loaded. You can register
* your object mappers or do other configurations.
*/
public function Register()
{
}
}
</code></pre>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="register">Application Register <small><a href="#content">#top</a></small></h4>
<p>
Application Class is an entry point for your code, after the installation of core framework modules the function(s) in this class will be run. You must define this class in a configuration file and only acceptable and auto run function is Register() function. This function is used to register globally variables, set object mappers, set pin checkers etc.
For example; Your app needs a database connection and you do not want to write username and password in each connection. You can define a object mapper in register function and access globally this variable in every place of your code.
<br><br>
<pre><code class="php">
<?php
use Ness\Configuration;
use Ness\Tool\ObjectMapper as omap;
...
/**---------------------------------------------------------*/
/** Application Class */
/**---------------------------------------------------------*/
class Application
{
/**
* This method is called when your application is loaded. You can register
* your object mappers or do other configurations.
*/
public function Register()
{
omap::MapNew("database", array(
"username"=>"db_user_name",
"password"=>"db_pass",
"host"=>"localhost"
));
}
}
</code>
</pre>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="methods">Class Methods <small><a href="#content">#top</a></small></h4>
<p>
<!---->
<h5>setEnvironment</h5>
<pre><code class="php">Configuration::setEnvironment(string $param);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">This function is used to set development environment.Accepted values: "development", "publish", "default".</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$param String</td>
</tr>
</table>
<br><br><br>
<!---->
<h5>setApplicationFolder & getApplicationFolder</h5>
<pre><code class="php">Configuration::setApplicationFolder(string $param);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">This function is used to set application folder for Ness framework's current config.</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$param String</td>
</tr>
</table>
<br>
<pre><code class="php">Configuration::getApplicationFolder();</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">This function is used to return application folder for Ness framework's current config.</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">String</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">None</td>
</tr>
</table>
<br><br><br>
<!---->
<h5>setRoot() & isRoot()</h5>
<pre><code class="php">Configuration::setRoot(Boolean $param);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">This function is used to determine if your application in server is in root directory or not. Set true if your app will run in root directory</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$param Boolean</td>
</tr>
</table>
<br>
<pre><code class="php">Configuration::isRoot();</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">you can use isRoot() to check the option;</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Boolean</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">None</td>
</tr>
</table>
<br><br><br>
<!---->
<h5>setApplicationUrl() & getApplicationUrl()</h5>
<pre><code class="php">Configuration::setApplicationUrl(string $prm="http://localhost/");</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">This function is very important, when you use response and route class your redirect url will be get from here.</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String</td>
</tr>
</table>
<br>
<pre><code class="php">Configuration::getApplicationUrl();</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">you can use getApplicationUrl() to return this value;</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">String</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">None</td>
</tr>
</table>
<br><br><br>
<!---->
<h5>setResourceFile() & getResourceFile()</h5>
Set resource file location of Ness framework.
<pre><code class="php">Configuration::setResourceFile(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String</td>
</tr>
</table>
<br>
Get the value with
<pre><code class="php">Configuration::getResourceFile() : string</code></pre>
<br><br><br>
<!---->
<h5>setUrlProtected() & isUrlProtected()</h5>
This function is used to prevent web site from unwanted url parameters.
<pre><code class="php">Configuration::setUrlProtected(Boolean $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm Boolean</td>
</tr>
</table>
<br>
This is a security setting. This setting must be activated in order to protect your web address from the parameters you do not want, and these special characters must be set by the method that follows
<pre><code class="php">Configuration::isUrlProtected() : Boolean</code></pre>
<br><br><br>
<!---->
<h5>UnwantedParameters()</h5>
Set an array for unwanted characters or words
<pre><code class="php">Configuration::UnwantedParameters(Array $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm Array</td>
</tr>
</table>
<br>
Example
<pre><code class="php">Configuration::UnwantedParameters(array("'", "_", "~"));</code></pre>
That means if your website gets visited with one of this three parameters user will be redirected.
<br><br><br>
<!---->
<h5>setTitle() & getTitle()</h5>
This function is used to set a title/name for your project.
<pre><code class="php">Configuration::setTitle(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String</td>
</tr>
</table>
<br>
Get the value with
<pre><code class="php">Configuration::getTitle() : string</code></pre>
<br><br><br>
<!---->
<h5>setVersion() & getVersion()</h5>
This function is used to set a version numer for your project.
<pre><code class="php">Configuration::setVersion(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String</td>
</tr>
</table>
<br>
Get the value with
<pre><code class="php">Configuration::getVersion() : string</code></pre>
<br><br><br>
<!---->
<h5>setDescription() & getDescription()</h5>
This function is used to set a description for your project.
<pre><code class="php">Configuration::setDescription(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td>Return</td>
<td colspan="2">void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String</td>
</tr>
</table>
<br>
Get the value with
<pre><code class="php">Configuration::getDescription() : string</code></pre>
<br><br><br>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="maintenance">Enable & Design Maintenance Mode <small><a href="#content">#top</a></small></h4>
<p>
This configuration is used to set maintenance mode of your application.if Maintenance Mode is enabled user will see a message on screen like 'Under Maintenance'.
<br>
<div class="text-center">
<img src="assets/img/screen_maintenance_mode.PNG" width="70%">
</div>
Find in your configuration file the line;
<pre><code class="php">Configuration::enableMaintenance(true);</code></pre>
and set true.
<div class="alert alert-info">
<strong>Design This Page; </strong>
<br>The view file for the 'Maintenance Mode' can be found in;
<span class="ug-code ug-type">[project_folder]/Application/View/systemArea/maintenancemodeView.php</span> <br>
and the controller for managing the maintenance mode can be found in<span class="ug-code ug-type">[project_folder]/Application/Controller/ErrorManagement/MaintenanceMode.php</span>
</div>
</p>
<br>
<!--end: topic-->
</div>
<!-- ========================content:end======================== -->
</div>
</div>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/nessphp.js"></script>
<script src="assets/js/highlightjs/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>