This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
/
bootstrap.php
1248 lines (1122 loc) · 30.9 KB
/
bootstrap.php
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Bootstraps the library environment.
*
* @package core
* @author Rob Tuley
* @version SVN: $Id$
* @license http://knotwerk.com/licence MIT
*/
// ------------------------- CONSTANTS
if (!defined('T_ROOT_DIR')) {
/**
* Root library directory.
*
* @global string T_ROOT_DIR
*/
define('T_ROOT_DIR',rtrim(rtrim(realpath(dirname(__FILE__)),'/'),'\\').
DIRECTORY_SEPARATOR);
}
if (!defined('T_CACHE_DIR')) {
/**
* Library cache directory.
*
* @global string T_CACHE_DIR
*/
define('T_CACHE_DIR',T_ROOT_DIR.'.cache'.DIRECTORY_SEPARATOR);
}
if (!defined('T_PHP_EXT')) {
/**
* PHP file extension.
*
* @global string T_PHP_EXT
*/
define('T_PHP_EXT',strrchr(__FILE__,'.'));
}
if (!defined('EOL')) {
/**
* Carriage Return.
*
* @global string EOL
*/
define('EOL',"\n");
}
/**
* Operating under windows.
*
* @global bool T_WINDOWS
*/
define('T_WINDOWS',strtoupper(substr(PHP_OS, 0, 3))==='WIN');
// ------------------------- UNICODE HANDLING
require_once T_ROOT_DIR.'unicode'.T_PHP_EXT;
// ------------------------- SHORTCUT FUNCTIONS
/**
* Returns the last member of an array.
*
* This simply wraps the in-built end() function but is useful as
* can be used directly on function return values as the array is
* copied directly into the function so doesn't fail with reference errors.
*
* @param array $data
* @return mixed last member in array
*/
function _end(array $data)
{
return end($data);
}
/**
* Returns the first member of an array.
*
* This simply wraps the in-built reset() function but is useful as
* can be used directly on function return values as the array is
* copied directly into the function so doesn't fail with reference errors.
*
* @param array $data
* @return mixed last member in array
*/
function _first(array $data)
{
return reset($data);
}
/**
* Executes a filter on a value if there is one.
*
* @param mixed $value value to filter
* @param function $filter filter to use to transform
* @return mixed filtered value
*/
function _transform($value,$filter)
{
if ($filter instanceof T_Filter) {
return $filter->transform($value);
} elseif ($filter) {
return call_user_func_array($filter,array($value));
} else {
return $value;
}
}
// ------------------------- FACTORIES
/**
* A factory to create an object.
*/
interface T_Factory
{
/**
* Creates a class instance.
*
* @param string $class classname
* @param array $args construct args
* @return object class instance
*/
function like($class,array $args=array());
/**
* Configure factory.
*
* This method is used to configure the DI container. It can be used to
* create singletons, and set the priority in which to create classes.
*
* <?php
* $factory = new T_Factory_Di);
* $factory->willUse(new T_Mysql_MasterOnly()); // setup singleton
* $factory->willUse('T_User'); // use T_User class
* ?>
*
* By default, the DI container will register the input for it's own
* classname, its parent classes and any interfaces it implements. If you
* want to be a bit more surgical in what you are registering a class for,
* you can include the optional second parameter, and specify the class you
* want to replace.
*
* <?php
* $factory->willUse('ReplacementController','OldController');
* ?>
*
* @param string $class classname
* @param string $instead_of to replace class
*/
function willUse($class,$instead_of=null);
}
/**
* Dependency injection factory.
*/
class T_Factory_Di implements T_Factory
{
/**
* Register self as the T_Factory population.
*/
function __construct()
{
$this->willUse($this); // register self for factory population
}
/**
* Stores class dependency lookup table.
*
* @var array
*/
protected $lkup = array();
/**
* Cached reflection classes.
*
* @var ReflectionClass[]
*/
protected $cache = array();
/**
* Configure DI container.
*
* @param string $class classname
* @param string $instead_of additional alias
*/
function willUse($class,$instead_of=null)
{
if (!is_null($instead_of)) {
$this->lkup[strtolower($instead_of)] = $class;
} else {
// registers class for its:
// 1. own name
// 2. parent class names
// 3. interface names
if (is_object($class)) {
if ($class instanceof T_Decorated) {
// in this case, the object is decorated, and we need to
// look *under* the decorators to get to the base class.
$classname = $class->getClass();
} else {
$classname = get_class($class);
}
} else {
$classname = $class;
}
// register interfaces
$reflect = $this->cache[strtolower($classname)] = new ReflectionClass($classname);
foreach ($reflect->getInterfaces() as $interface) {
$this->lkup[strtolower($interface->getName())] = $class;
}
do { // register under own and parent class names
$this->lkup[strtolower($classname)] = $class;
} while ($classname=get_parent_class($classname));
}
return $this; // fluent interface
}
/**
* Applies DI container to return class instance.
*
* @param string $class classname
* @param array $args construct args not covered by DI
* @return object class instance
*/
function like($class,array $args=array())
{
$key = strtolower($class); // case-insensitive key
// translate class from config
$class = isset($this->lkup[$key]) ? $this->lkup[$key] : $class;
if (is_object($class)) {
return $class; // singleton defined
}
// create reflection
$c_key = strtolower($class); // case-insensitive again, might be
// different from lkup key if mapped to
// different class
if (!isset($this->cache[$c_key])) {
$reflect = $this->cache[$c_key] = new ReflectionClass($class);
} else {
$reflect = $this->cache[$c_key];
}
// check can be instantiated
if (!$reflect->isInstantiable()) {
throw new RuntimeException("$class is not instantiable (check DI config)");
}
// examine constructor params
$construct = $reflect->getConstructor();
if (!$construct || $construct->getNumberOfParameters()==0) {
return new $class(); // shortcut when no params
}
$c_args = array();
foreach ($construct->getParameters() as $p) {
$name = $p->getName();
if (array_key_exists($name,$args)) {
$c_args[] = $args[$name];
} elseif (!$p->isOptional() && $hint=$p->getClass()) {
$this->cache[strtolower($hint->getName())] = $hint;
$c_args[] = $this->like($hint->getName());
// ^ populate deps by using DI!
} elseif (!$p->isOptional()) {
// not an optional arg, with no type hint. problem.
throw new RuntimeException("No value for arg $name in class $class");
}
}
return $reflect->newInstanceArgs($c_args);
}
}
// ------------------------- FIND RULES
/**
* A rule to find an item.
*/
interface T_Find_Rule
{
/**
* Finds an item.
*
* @param string $query
* @param string $type
* @return mixed either the found item or false if not found
*/
function find($query,$type=null);
}
/**
* Load files from a particular directory.
*/
class T_Find_FileInDir implements T_Find_Rule
{
/**
* Directory from which to load.
*
* @var string
*/
protected $dir;
/**
* Type of file.
*
* @var string
*/
protected $type;
/**
* Filter to apply to query.
*
* @var function
*/
protected $filter;
/**
* Create directory finder.
*
* @param string $dir
* @param string $type
* @param function $filter optional filter to apply to search string
*/
function __construct($dir,$type,$filter=null)
{
$this->dir = rtrim(rtrim($dir,'/'),'\\').DIRECTORY_SEPARATOR;
$this->type = $type;
$this->filter = $filter;
}
/**
* Find an item.
*
* @param string $query
* @param string $type e.g. 'class'
* @return mixed either the found item or false if not found
*/
function find($query,$type=null)
{
// skip if types do not match
if ($type && $this->type && strcmp($type,$this->type)!==0) return false;
// try to find filepath
if ($this->filter) $filter->transform($query);
$path = $this->dir.$query.'.'.$type;
if (is_file($path)) {
return $path;
}
return false;
}
}
/**
* Load classes from a particular directory.
*/
class T_Find_ClassInDir extends T_Find_FileInDir
{
/**
* Prefix to strip.
*
* @var string
*/
protected $prefix;
/**
* Maps classnames to standard directory structure.
*
* e.g. Some_Class_Name => Some/Class/Name.php
*
* @param string $dir
* @param string $prefix
*/
function __construct($dir,$prefix=null)
{
parent::__construct($dir,substr(T_PHP_EXT,1));
$this->prefix = $prefix;
}
/**
* Find an item.
*
* @param string $query
* @param string $type e.g. 'class'
* @return mixed either the found item or false if not found
*/
function find($query,$type=null)
{
// check prefix matches
if ($this->prefix &&
strncmp($query,$this->prefix,strlen($this->prefix))!==0) {
return false;
}
$query = str_replace('_',DIRECTORY_SEPARATOR,substr($query,strlen($this->prefix)));
return parent::find($query,$type);
}
}
// ------------------------- ENVIRONMENT
/**
* The environment code is operating in.
*/
interface T_Environment extends T_Factory,T_Find_Rule
{
/**
* Get an environment input.
*
* @param string $name
* @return T_Cage_Array
*/
function input($name);
/**
* Adds a rule to the environment.
*
* @param T_Find_Rule $rule
* @return T_Environment fluent
*/
function addRule(T_Find_Rule $rule);
}
/**
* Environment when operating within application.
*/
interface T_Environment_UrlContext extends T_Environment
{
/**
* Sets the server root URL.
*
* @param T_Url $root web root
*/
function setAppRoot($root);
/**
* Gets the server root URL.
*
* @return T_Url web root
*/
function getAppRoot();
/**
* Gets the URL of the request.
*
* @return T_Url URL object
*/
function getRequestUrl();
/**
* Gets the HTTP method.
*
* This returns the Http method (HEAD,GET,POST,PUT,DELETE) that the resource
* has been requested with.
*
* @param function $filter optional filter
* @return string HTTP request method
*/
function getMethod($filter=null);
/**
* Whether the HTTPs method is a particular value.
*
* @return bool
*/
function isMethod($method);
/**
* Is the request a XMLHttpRequest?
*
* Examines the headers to see if the use of XMLHttpRequest is flagged in
* the X-Requested-With header. This is usually set by the standard JS
* libraries like jQuery, Prototype, etc.
*
* @return bool
*/
function isAjax();
}
/**
* Environment for code execution.
*/
abstract class T_Environment_Autoload extends T_Factory_Di
implements T_Environment
{
/**
* Stack of rules.
*
* @var T_Find_Rule
*/
protected $stack = array();
/**
* Environment inputs
*
* @var array
*/
protected $input = false;
/**
* Setup autoload and error handling.
*/
function __construct()
{
parent::__construct();
spl_autoload_register(array($this,'handleAutoload'));
set_exception_handler(array($this,'handleException'));
set_error_handler(array($this,'handleError'));
date_default_timezone_set('UTC');
if (version_compare(PHP_VERSION,'5.3.0','<')) set_magic_quotes_runtime(0);
ini_set('auto_detect_line_endings',1);
$this->willUse(new T_Exception_Handler()); // single exception handler
}
/**
* Find an item.
*
* @param string $query
* @param string $type e.g. 'class'
* @return mixed either the found item or false if not found
*/
function find($query,$type=null)
{
foreach ($this->stack as $rule) {
if (($found=$rule->find($query,$type))!==false) return $found;
}
return false;
}
/**
* Get an environment input.
*
* @param string $name
* @return T_Cage_Array
*/
function input($name)
{
if (false===$this->input) {
$this->input = $this->parseInput();
}
if (!array_key_exists($name,$this->input)) {
return null;
}
return $this->input[$name];
}
/**
* Initialise input.
*
* @return array
*/
abstract protected function parseInput();
/**
* Adds a rule to the stack.
*
* @param T_Find_Rule $rule
* @return T_Find fluent
*/
function addRule(T_Find_Rule $rule)
{
array_unshift($this->stack,$rule);
return $this;
}
/**
* Autoload
*
* @param string $name classname
* @return bool whether the class could be loaded.
*/
function handleAutoload($name)
{
$found = $this->find($name,'php');
if ($found) {
require_once($found);
return true;
}
return false;
}
/**
* Custom error handler.
*
* @param int $code error code
* @param string $string error message
* @param string $filename filename where the error occurred
* @param int $line line number of error
* @param array $scope variable values in the scope of the error
* @return bool confirms whether the function has handled the error or not
*/
function handleError($code,$string,$filename,$line,$scope)
{
$level = ini_get('error_reporting');
if (!($code & $level)) {
return true; // error_reporting is off for this code
}
// convert error to an exception
$e = new ErrorException($string,0,$code,$filename,$line);
// try to handle error using in-built exception handler
if (class_exists('T_Exception_Handler') &&
$this->like('T_Exception_Handler')->handle($e)) {
return true; // error has been handled
}
// otherwise, throw and hope it gets caught.
throw $e;
}
/**
* Handle exception.
*
* @param Exception $exception
* @return bool whether the exception was handled.
*/
function handleException($exception)
{
if ($exception instanceof ErrorException) {
// we have already tried to handle this exception in the error
// handler before it was thrown so we don't repeat ourselves.
$handled = false;
} else {
$handled = $this->like('T_Exception_Handler')
->handle($exception);
}
if (!$handled) {
if (ini_get('display_errors')) echo $exception;
}
return $handled;
}
}
/**
* Environment when operating at the command line.
*/
class T_Environment_Terminal extends T_Environment_Autoload
{
/**
* Setup terminal environment.
*/
function __construct()
{
parent::__construct();
// Handle fact that we may not be using the php cli environment. If we
// are using CGI, we need to make some corrections.
// @see http://www.sitepoint.com/print/php-command-line-1/
if (php_sapi_name() == 'cgi') {
// output buffering
@ob_end_flush();
ob_implicit_flush(TRUE);
// PHP ini settings
set_time_limit(0);
ini_set('track_errors',1);
ini_set('html_errors',0);
// define stream constants
define('STDIN', fopen('php://stdin','r'));
define('STDOUT', fopen('php://stdout','w'));
define('STDERR', fopen('php://stderr','w'));
// close the streams on script termination
register_shutdown_function(
create_function('',
'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;')
);
}
}
/**
* Parse command line inputs.
*
* By default, the terminal environment parses all single letter flags as
* a optional input.
*
* @return array
*/
protected function parseInput()
{
/*
Arguments are difficult to handle. The getopts function is the best way
but is not available on windows until PHP 5.3.0. Until this, leave the
child evenvironment to define its own arg handling.
*/
return array();
}
}
/**
* Environment when operating under an HTTP request.
*/
class T_Environment_Http extends T_Environment_Autoload
implements T_Environment_UrlContext
{
/**
* App root URL.
*
* @var T_Url
*/
protected $root = null;
/**
* URL of request.
*
* @var T_Url
*/
protected $url = null;
/**
* Request method.
*
* @var string
*/
protected $method = null;
/**
* Create HTTP environment.
*/
function __construct()
{
parent::__construct();
// add session handler to factory
$this->willUse(new T_Session_Handler());
}
/**
* Sets the server root URL.
*
* @param T_Url $root web root
*/
function setAppRoot($root)
{
$this->root = $root;
if ($c=$this->input('COOKIE')) $c->setRootUrl($root);
return $this;
}
/**
* Gets the server root URL.
*
* @return T_Url web root
*/
function getAppRoot()
{
if ($this->root) {
return clone($this->root);
} else {
return null;
}
}
/**
* Gets the URL of the request.
*
* @return T_Url URL object
*/
function getRequestUrl()
{
$this->parseUrlAndMethod(); // ini method and URL
return ($this->url) ? clone($this->url) : false;
}
/**
* Gets the HTTP method.
*
* This returns the Http method (HEAD,GET,POST,PUT,DELETE) that the resource
* has been requested with.
*
* @param function $filter optional filter
* @return string HTTP request method
*/
function getMethod($filter=null)
{
$this->parseUrlAndMethod(); // ini method and URL
return _transform($this->method,$filter);
}
/**
* Whether the HTTPs method is a particular value.
*
* @return bool
*/
function isMethod($method)
{
$this->parseUrlAndMethod(); // ini method and URL
return strcasecmp($this->method,$method)===0;
}
/**
* Is the request a XMLHttpRequest?
*
* Examines the headers to see if the use of XMLHttpRequest is flagged in
* the X-Requested-With header. This is usually set by the standard JS
* libraries like jQuery, Prototype, etc.
*
* @return bool
*/
function isAjax()
{
$key = 'HTTP_X_REQUESTED_WITH';
if ($server=$this->input('SERVER')) {
if ($server->exists($key)) {
$val = $server->asScalar($key)->uncage();
return strcasecmp($val,'XMLHttpRequest')===0;
}
}
return false;
}
/**
* Parse GET, POST, FILES and COOKIE inputs.
*
* @return array
*/
protected function parseInput()
{
$get = $_GET;
$post = $_POST;
$cookie = $_COOKIE;
if (get_magic_quotes_gpc()) {
$f = new T_Filter_NoMagicQuotes();
$get = $f->transform($get);
$post = $f->transform($post);
$cookie = $f->transform($cookie);
}
$data = array();
$data['GET'] = new T_Cage_Array($get);
$files = isset($_FILES) ? $_FILES : array();
$data['POST'] = new T_Cage_Post($post,$files);
$data['SERVER'] = new T_Cage_Array($_SERVER);
$data['COOKIE'] = new T_Cage_Cookie($cookie);
return $data;
}
/**
* Initialise the request.
*
* @return void
*/
protected function parseUrlAndMethod()
{
if (!is_null($this->method)) return; // already initialised
$server = $this->input('SERVER');
try {
$scheme = $this->isSsl($server) ? 'https' : 'http';
/**
* Get hostname.
*
* A possible alternative to SERVER_NAME is HTTP_HOST but this
* value is set from the user via a 'Host:' header and cannot be
* trusted. If it was used it might be possible to create login forms
* that get submitted to another server for example. SERVER_NAME is
* taken from the Virtual Host settings and cannot be influenced by
* the user.
*/
$host = $server->asScalar('SERVER_NAME')->uncage();
/**
* Get the request URI.
*
* We use the global REQUEST_URI with the query path and fragment
* stripped off to use as the controller mapping path. Again, XSS
* attacks might be included in this path, but they are useless as they
* won't match a controller mapping and a 404 error will result.
*/
$path = $server->asScalar('REQUEST_URI')
->filter(new T_Filter_UrlPath())
->uncage();
/**
* Get request method.
*/
$method = $server->asScalar('REQUEST_METHOD')
->filter('mb_strtoupper')
->uncage();
/**
* Set URL, subspace and method
*/
$this->url = new T_Url($scheme,$host,$path);
$this->method = $method;
} catch (T_Exception_Cage $e) {
// unable to parse out the server URL.
$this->url = false;
$this->method = false;
}
}
/**
* Detects whether the request is HTTPS
*
* @param T_Cage_Array $server server superglobal data
* @return bool whether the request has been made over a secure connection
*/
protected function isSsl(T_Cage_Array $server)
{
// extract HTTPS status and port number from $_SERVER
$https = null;
if ($server->exists('HTTPS')) {
$https = $server->asScalar('HTTPS')->uncage();
}
$port = null;
if ($server->exists('SERVER_PORT')) {
$port = $server->asScalar('SERVER_PORT')
->filter(new T_Validate_Int())
->uncage();
}
// test data
return (strcasecmp($https,'on')===0 || $https==1 || $port==443);
}
}
// -------- DEFAULT HANDLERS (session, exception)
/**
* Encapsulates session data.
*
* @package core
*/
class T_Session_Handler
{
/**
* Namespace delimiter.
*/
const NS_DELIMIT = '/';
/**
* Session drivers.
*
* @var T_Session_Driver[]
*/
protected $drivers = array();
/**
* Default driver key.
*
* @var int
*/
protected $default_driver = false;
/**
* The driver keys that are responsible for each namespace.
*
* @var array
*/
protected $ns_driver = array();
/**
* Data without a namespace.
*
* @var array
*/
protected $data = array();
/**
* Stores the text namespaces for each index.
*
* @var array
*/
protected $ns = array();
/**
* Whether SESSION has already been started.
*
* @var bool
*/
protected $ini = false;
/**
* Initialise session.
*
* @return void
*/
protected function ini()
{
if ($this->ini) {
return $this;
}
// if no drivers are present, add a default normal session driver.