-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.php
More file actions
68 lines (57 loc) · 1.51 KB
/
Core.php
File metadata and controls
68 lines (57 loc) · 1.51 KB
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
<?php
/**
* @author : Jakiboy
* @package : FloatPHP
* @subpackage : Kernel Component
* @version : 1.5.x
* @copyright : (c) 2018 - 2025 Jihad Sinnaour <me@jihadsinnaour.com>
* @link : https://floatphp.com
* @license : MIT
*
* This file is a part of FloatPHP Framework.
*/
declare(strict_types=1);
namespace FloatPHP\Kernel;
use FloatPHP\Classes\Http\Router;
use FloatPHP\Helpers\Framework\Installer;
final class Core
{
use TraitException,
\FloatPHP\Helpers\Framework\tr\TraitDatable,
\FloatPHP\Helpers\Framework\tr\TraitSessionable;
/**
* Init Core.
*
* @access public
* @param array $config
*/
public function __construct(array $config = [])
{
$config = (new Installer())->default($config);
// Setup
if ( $config['--enable-setup'] === true ) {
if ( !Installer::isInstalled() ) {
$db = ($config['--enable-database'] === true) ?: false;
(new Installer())->setup($db);
}
}
// X-Powered-By header
if ( $config['--disable-powered-by'] !== true ) {
$generator = $config['--powered-by'] ?? 'FloatPHP';
header("X-Powered-By: {$generator}");
}
// Start session
if ( $config['--disable-session'] !== true ) {
$this->startSession();
$this->setSession('--default-lang', $config['--default-lang']);
}
// Maintenance
if ( $config['--enable-maintenance'] == true ) {
$this->throwError(503);
}
// Timezone
$this->setDefaultTimezone($config['--default-timezone']);
// Start routing
(new Middleware(router: new Router()))->dispatch();
}
}