create-prisma-php-app 1.8.15 → 1.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.php +45 -8
- package/dist/settings/paths.php +2 -2
- package/package.json +1 -1
package/dist/bootstrap.php
CHANGED
|
@@ -22,18 +22,19 @@ function determineContentToInclude()
|
|
|
22
22
|
$uri = trim($requestUri, '/');
|
|
23
23
|
$baseDir = __DIR__ . '/src/app';
|
|
24
24
|
$includePath = '';
|
|
25
|
+
$layoutsToInclude = [];
|
|
25
26
|
$metadata = $metadata[$uri] ?? $metadata['default'];
|
|
26
27
|
writeRoutes();
|
|
27
28
|
|
|
28
29
|
$isDirectAccessToPrivateRoute = preg_match('/^_/', $uri);
|
|
29
30
|
if ($isDirectAccessToPrivateRoute) {
|
|
30
|
-
return ['path' => $includePath];
|
|
31
|
+
return ['path' => $includePath, 'layouts' => $layoutsToInclude, 'uri' => $uri];
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
if ($uri) {
|
|
34
35
|
$groupFolder = findGroupFolder($uri);
|
|
35
36
|
if ($groupFolder) {
|
|
36
|
-
$path = $baseDir
|
|
37
|
+
$path = $baseDir . $groupFolder;
|
|
37
38
|
if (file_exists($path)) {
|
|
38
39
|
$includePath = $path;
|
|
39
40
|
}
|
|
@@ -44,17 +45,34 @@ function determineContentToInclude()
|
|
|
44
45
|
if (file_exists($path)) {
|
|
45
46
|
$includePath = $path;
|
|
46
47
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$currentPath = $baseDir;
|
|
51
|
+
$getGroupFolder = getGroupFolder($groupFolder);
|
|
52
|
+
$modifiedUri = $uri;
|
|
53
|
+
if (!empty($getGroupFolder)) {
|
|
54
|
+
$modifiedUri = $getGroupFolder;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
foreach (explode('/', $modifiedUri) as $segment) {
|
|
58
|
+
if (empty($segment)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
$currentPath .= '/' . $segment;
|
|
62
|
+
$potentialLayoutPath = $currentPath . '/layout.php';
|
|
63
|
+
if (file_exists($potentialLayoutPath)) {
|
|
64
|
+
$layoutsToInclude[] = $potentialLayoutPath;
|
|
51
65
|
}
|
|
52
66
|
}
|
|
67
|
+
|
|
68
|
+
if (empty($layoutsToInclude)) {
|
|
69
|
+
$layoutsToInclude[] = $baseDir . '/layout.php';
|
|
70
|
+
}
|
|
53
71
|
} else {
|
|
54
72
|
$includePath = $baseDir . '/index.php';
|
|
55
73
|
}
|
|
56
74
|
|
|
57
|
-
return ['path' => $includePath];
|
|
75
|
+
return ['path' => $includePath, 'layouts' => $layoutsToInclude, 'uri' => $uri];
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
function checkForDuplicateRoutes()
|
|
@@ -152,10 +170,23 @@ function matchGroupFolder($constructedPath): ?string
|
|
|
152
170
|
return $bestMatch;
|
|
153
171
|
}
|
|
154
172
|
|
|
173
|
+
function getGroupFolder($uri): string
|
|
174
|
+
{
|
|
175
|
+
$lastSlashPos = strrpos($uri, '/');
|
|
176
|
+
$pathWithoutFile = substr($uri, 0, $lastSlashPos);
|
|
177
|
+
|
|
178
|
+
if (preg_match('/\(([^)]+)\)[^()]*$/', $pathWithoutFile, $matches)) {
|
|
179
|
+
return $pathWithoutFile;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
|
|
155
185
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
|
156
186
|
$domainName = $_SERVER['HTTP_HOST'];
|
|
157
|
-
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
|
187
|
+
$scriptPath = dirname($_SERVER['SCRIPT_NAME']) . '/';
|
|
158
188
|
$baseUrl = $protocol . $domainName . rtrim($scriptPath, '/') . '/';
|
|
189
|
+
$pathname = "";
|
|
159
190
|
|
|
160
191
|
ob_start();
|
|
161
192
|
|
|
@@ -189,8 +220,14 @@ try {
|
|
|
189
220
|
$result = determineContentToInclude();
|
|
190
221
|
checkForDuplicateRoutes();
|
|
191
222
|
$contentToInclude = $result['path'] ?? '';
|
|
223
|
+
$layoutsToInclude = $result['layouts'] ?? [];
|
|
224
|
+
$pathname = $result['uri'] ? "/" . $result['uri'] : "/";
|
|
192
225
|
|
|
193
226
|
if (!empty($contentToInclude)) {
|
|
227
|
+
foreach ($layoutsToInclude as $layoutPath) {
|
|
228
|
+
require_once $layoutPath;
|
|
229
|
+
}
|
|
230
|
+
|
|
194
231
|
require_once $contentToInclude;
|
|
195
232
|
} else {
|
|
196
233
|
require_once "not-found.php";
|
package/dist/settings/paths.php
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// Absolute path
|
|
4
4
|
define("SETTINGS_PATH", dirname(__FILE__));
|
|
5
5
|
define("PUBLIC_PATH", dirname(SETTINGS_PATH) . "/public");
|
|
6
|
-
define("PRISMA_LIB_PATH", dirname(SETTINGS_PATH) . "/src/
|
|
6
|
+
define("PRISMA_LIB_PATH", dirname(SETTINGS_PATH) . "/src/Lib/Prisma");
|
|
7
7
|
define("SRC_PATH", dirname(SETTINGS_PATH) . "/src");
|
|
8
8
|
define("APP_PATH", dirname(SETTINGS_PATH) . "/src/app");
|
|
9
9
|
define("API_PATH", dirname(SETTINGS_PATH) . "/src/app/api");
|
|
10
|
-
define("LIB_PATH", dirname(SETTINGS_PATH) . "/src/
|
|
10
|
+
define("LIB_PATH", dirname(SETTINGS_PATH) . "/src/Lib");
|
|
11
11
|
define("DOCUMENT_PATH", dirname(SETTINGS_PATH));
|