create-prisma-php-app 1.11.8 → 1.11.10

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.
@@ -18,6 +18,7 @@ function determineContentToInclude()
18
18
  $scriptUrl = $_SERVER['REQUEST_URI'];
19
19
  $scriptUrl = explode('?', $scriptUrl, 2)[0];
20
20
  $uri = $_SERVER['SCRIPT_URL'] ?? uriExtractor($scriptUrl);
21
+ $uri = ltrim($uri, '/');
21
22
  $baseDir = APP_PATH;
22
23
  $includePath = '';
23
24
  $layoutsToInclude = [];
@@ -249,9 +250,12 @@ $childContent = "";
249
250
  function containsChildContent($filePath)
250
251
  {
251
252
  $fileContent = file_get_contents($filePath);
252
- $pattern = '/<\?(?:php)?[^?]*\$childContent[^?]*\?>/is';
253
-
254
- if (preg_match($pattern, $fileContent)) {
253
+ if (
254
+ (strpos($fileContent, 'echo $childContent') === false &&
255
+ strpos($fileContent, 'echo $childContent;') === false) &&
256
+ (strpos($fileContent, '<?= $childContent ?>') === false) &&
257
+ (strpos($fileContent, '<?= $childContent; ?>') === false)
258
+ ) {
255
259
  return true;
256
260
  } else {
257
261
  return false;
@@ -261,8 +265,12 @@ function containsChildContent($filePath)
261
265
  function containsContent($filePath)
262
266
  {
263
267
  $fileContent = file_get_contents($filePath);
264
- $pattern = '/<\?(?:php\s+)?(?:=|echo|print)\s*\$content\s*;?\s*\?>/i';
265
- if (preg_match($pattern, $fileContent)) {
268
+ if (
269
+ (strpos($fileContent, 'echo $content') === false &&
270
+ strpos($fileContent, 'echo $content;') === false) &&
271
+ (strpos($fileContent, '<?= $content ?>') === false) &&
272
+ (strpos($fileContent, '<?= $content; ?>') === false)
273
+ ) {
266
274
  return true;
267
275
  } else {
268
276
  return false;
@@ -299,8 +307,10 @@ try {
299
307
  $parentLayoutPath = APP_PATH . '/layout.php';
300
308
  $isParentLayout = !empty($layoutsToInclude) && strpos($layoutsToInclude[0], 'src/app/layout.php') !== false;
301
309
 
302
- if (!containsContent($parentLayoutPath)) {
303
- $content .= "<div class='error'>The parent layout file does not contain &lt;?php echo \$content ?&gt; Or &lt;?= \$content ?&gt;<br>" . "<strong>$parentLayoutPath</strong></div>";
310
+ $isContentIncluded = false;
311
+ $isChildContentIncluded = false;
312
+ if (containsContent($parentLayoutPath)) {
313
+ $isContentIncluded = true;
304
314
  }
305
315
 
306
316
  ob_start();
@@ -311,13 +321,16 @@ try {
311
321
  $childContent = ob_get_clean();
312
322
  }
313
323
  foreach (array_reverse($layoutsToInclude) as $layoutPath) {
314
- ob_start();
315
- if ($parentLayoutPath === $layoutPath) continue;
324
+ if ($parentLayoutPath === $layoutPath) {
325
+ continue;
326
+ }
327
+
316
328
  if (containsChildContent($layoutPath)) {
317
- require_once $layoutPath;
318
- } else {
319
- $content .= "<div class='error'>The layout file does not contain &lt;?php echo \$childContent ?&gt; Or &lt;?= \$childContent ?&gt<br>" . "<strong>$layoutPath</strong></div>";
329
+ $isChildContentIncluded = true;
320
330
  }
331
+
332
+ ob_start();
333
+ require_once $layoutPath;
321
334
  $childContent = ob_get_clean();
322
335
  }
323
336
  } else {
@@ -332,11 +345,19 @@ try {
332
345
  $childContent = ob_get_clean();
333
346
  }
334
347
 
335
- $content .= $childContent;
336
-
337
- ob_start();
338
- require_once APP_PATH . '/layout.php';
339
- echo ob_get_clean();
348
+ if (!$isContentIncluded && !$isChildContentIncluded) {
349
+ $content .= $childContent;
350
+ ob_start();
351
+ require_once APP_PATH . '/layout.php';
352
+ } else {
353
+ if ($isContentIncluded) {
354
+ $content .= "<div class='error'>The parent layout file does not contain &lt;?php echo \$content; ?&gt; Or &lt;?= \$content ?&gt;<br>" . "<strong>$parentLayoutPath</strong></div>";
355
+ modifyOutputLayoutForError($content);
356
+ } else {
357
+ $content .= "<div class='error'>The layout file does not contain &lt;?php echo \$childContent; ?&gt; or &lt;?= \$childContent ?&gt;<br><strong>$layoutPath</strong></div>";
358
+ modifyOutputLayoutForError($content);
359
+ }
360
+ }
340
361
  } catch (Throwable $e) {
341
362
  $content = ob_get_clean();
342
363
  $content .= "<div class='error'>Unhandled Exception: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</div>";
@@ -1,6 +1,6 @@
1
1
  <div class="flex flex-col min-h-[100vh]">
2
2
  <header class="px-4 lg:px-6 h-14 flex items-center">
3
- <a class="flex items-center justify-center" href="#">
3
+ <a class="flex items-center justify-center" href="/">
4
4
  <img class="h-10 w-10" src="<?= $baseUrl ?>assets/images/prisma-php.png" alt="Prisma PHP">
5
5
  <span class="sr-only">Prisma PHP</span>
6
6
  </a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.11.8",
3
+ "version": "1.11.10",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",