create-prisma-php-app 1.11.9 → 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.
@@ -250,9 +250,12 @@ $childContent = "";
250
250
  function containsChildContent($filePath)
251
251
  {
252
252
  $fileContent = file_get_contents($filePath);
253
- $pattern = '/<\?(?:php)?[^?]*\$childContent[^?]*\?>/is';
254
-
255
- 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
+ ) {
256
259
  return true;
257
260
  } else {
258
261
  return false;
@@ -262,8 +265,12 @@ function containsChildContent($filePath)
262
265
  function containsContent($filePath)
263
266
  {
264
267
  $fileContent = file_get_contents($filePath);
265
- $pattern = '/<\?(?:php\s+)?(?:=|echo|print)\s*\$content\s*;?\s*\?>/i';
266
- 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
+ ) {
267
274
  return true;
268
275
  } else {
269
276
  return false;
@@ -300,8 +307,10 @@ try {
300
307
  $parentLayoutPath = APP_PATH . '/layout.php';
301
308
  $isParentLayout = !empty($layoutsToInclude) && strpos($layoutsToInclude[0], 'src/app/layout.php') !== false;
302
309
 
303
- if (!containsContent($parentLayoutPath)) {
304
- $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;
305
314
  }
306
315
 
307
316
  ob_start();
@@ -312,13 +321,16 @@ try {
312
321
  $childContent = ob_get_clean();
313
322
  }
314
323
  foreach (array_reverse($layoutsToInclude) as $layoutPath) {
315
- ob_start();
316
- if ($parentLayoutPath === $layoutPath) continue;
324
+ if ($parentLayoutPath === $layoutPath) {
325
+ continue;
326
+ }
327
+
317
328
  if (containsChildContent($layoutPath)) {
318
- require_once $layoutPath;
319
- } else {
320
- $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;
321
330
  }
331
+
332
+ ob_start();
333
+ require_once $layoutPath;
322
334
  $childContent = ob_get_clean();
323
335
  }
324
336
  } else {
@@ -333,11 +345,19 @@ try {
333
345
  $childContent = ob_get_clean();
334
346
  }
335
347
 
336
- $content .= $childContent;
337
-
338
- ob_start();
339
- require_once APP_PATH . '/layout.php';
340
- 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
+ }
341
361
  } catch (Throwable $e) {
342
362
  $content = ob_get_clean();
343
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.9",
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",