-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpaths.php
More file actions
146 lines (127 loc) · 4.17 KB
/
paths.php
File metadata and controls
146 lines (127 loc) · 4.17 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
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
<?php
defined('DS') or exit('No direct access.');
/*
|----------------------------------------------------------------
| Environment aplikasi
|----------------------------------------------------------------
|
| Rakit menggunakan pendekatan sederhana terhadap environment.
| Cukup tentukan URL mana yang termasuk dalam environment itu,
| saat aplikasi diakses dari URL yang sesuai dengan pola tersebut,
| konten file konfigurasi environment tersebut akan ditimpa.
|
*/
$environments = [
'local' => ['http://localhost*', 'http://127.0.0.1*', '*.test'],
// ..
];
// --------------------------------------------------------------
// Path ke direktori paket default.
// --------------------------------------------------------------
$paths = ['app' => 'application'];
// --------------------------------------------------------------
// Path ke file key.
// --------------------------------------------------------------
$paths['rakit_key'] = 'key.php';
// --------------------------------------------------------------
// Path ke direktori sistem.
// --------------------------------------------------------------
$paths['system'] = 'system';
// --------------------------------------------------------------
// Path ke direktori utama paket.
// --------------------------------------------------------------
$paths['package'] = 'packages';
// --------------------------------------------------------------
// Path ke direktori storage.
// --------------------------------------------------------------
$paths['storage'] = 'storage';
// --------------------------------------------------------------
// Path ke direktori aset.
// --------------------------------------------------------------
$paths['assets'] = 'assets';
// --------------------------------------------------------------
// Ubah direktori kerja ke direktori root.
// --------------------------------------------------------------
chdir(__DIR__);
// --------------------------------------------------------------
// Definisikan path ke base direktori.
// --------------------------------------------------------------
$GLOBALS['rakit_paths']['base'] = __DIR__ . DS;
// --------------------------------------------------------------
// Defininisikan konstanta lain yang belum ada.
// --------------------------------------------------------------
foreach ($paths as $name => $path) {
if (!isset($GLOBALS['rakit_paths'][$name])) {
$GLOBALS['rakit_paths'][$name] = ('rakit_key' === $name)
? $GLOBALS['rakit_paths']['base'] . $path
: realpath($path) . DS;
}
}
/**
* Fungsi global untuk akses path.
*
* <code>
*
* $storage = path('storage');
*
* </code>
*
* @param string $path
*
* @return string
*/
function path($path)
{
return $GLOBALS['rakit_paths'][$path];
}
/**
* Fungsi global untuk setting path.
*
* @param string $path
* @param string $value
*/
function set_path($path, $value)
{
$GLOBALS['rakit_paths'][$path] = $value;
}
// --------------------------------------------------------------
// Polyfill untuk Throwable interface (PHP < 7.0).
// --------------------------------------------------------------
if (PHP_VERSION_ID < 70000 && !interface_exists('Throwable')) {
interface Throwable
{
public function getMessage();
public function getCode();
public function getFile();
public function getLine();
public function getTrace();
public function getTraceAsString();
public function getPrevious();
public function __toString();
}
}
// --------------------------------------------------------------
// Polyfill untuk atribut #[\ReturnTypeWillChange].
// --------------------------------------------------------------
if (PHP_VERSION_ID < 80000) {
final class Attribute
{
const TARGET_CLASS = 1;
const TARGET_FUNCTION = 2;
const TARGET_METHOD = 4;
const TARGET_PROPERTY = 8;
const TARGET_CLASS_CONSTANT = 16;
const TARGET_PARAMETER = 32;
const TARGET_ALL = 63;
}
}
if (PHP_VERSION_ID < 80100) {
#[Attribute(Attribute::TARGET_METHOD)]
final class ReturnTypeWillChange
{
public function __construct()
{
// ..
}
}
}