create-prisma-php-app 1.8.18 → 1.8.20

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.
@@ -190,16 +190,12 @@ $pathname = "";
190
190
 
191
191
  ob_start();
192
192
 
193
- set_error_handler(function ($severity, $message, $file, $line) {
194
- throw new ErrorException($message, 0, $severity, $file, $line);
195
- });
196
-
197
- set_exception_handler(function ($exception) {
198
- echo "<div class='error'>An error occurred: " . $exception->getMessage() . "</div>";
193
+ set_error_handler(function ($severity, $message, $file, $line) use (&$content) {
194
+ echo "<div class='error'>An error occurred: $severity - $message in $file on line $line</div>";
195
+ $content .= ob_get_clean();
199
196
  });
200
197
 
201
198
  set_exception_handler(function ($exception) use (&$content) {
202
- ob_start();
203
199
  echo "<div class='error'>An error occurred: " . htmlspecialchars($exception->getMessage(), ENT_QUOTES, 'UTF-8') . "</div>";
204
200
  $content .= ob_get_clean();
205
201
  });
@@ -207,12 +203,8 @@ set_exception_handler(function ($exception) use (&$content) {
207
203
  register_shutdown_function(function () use (&$content) {
208
204
  $error = error_get_last();
209
205
  if ($error && ($error['type'] === E_ERROR || $error['type'] === E_PARSE || $error['type'] === E_CORE_ERROR || $error['type'] === E_COMPILE_ERROR)) {
210
- ob_start();
211
206
  echo "<div class='error'>An error occurred: " . $error['message'] . "</div>";
212
- $errorContent = ob_get_clean();
213
- $content = $errorContent . $content;
214
- ob_clean();
215
- echo "<html><body>{$content}</body></html>";
207
+ $content .= ob_get_clean();
216
208
  }
217
209
  });
218
210
 
@@ -222,9 +214,15 @@ try {
222
214
  $contentToInclude = $result['path'] ?? '';
223
215
  $layoutsToInclude = $result['layouts'] ?? [];
224
216
  $pathname = $result['uri'] ? "/" . $result['uri'] : "/";
217
+ if (!empty($layoutsToInclude))
218
+ $isParentLayout = strpos($layoutsToInclude[0], 'src/app/layout.php') !== false;
219
+ else
220
+ $isParentLayout = false;
225
221
 
226
- ob_start();
227
222
  if (!empty($contentToInclude)) {
223
+ if (!$isParentLayout) {
224
+ require_once $contentToInclude;
225
+ }
228
226
  $childContent = ob_get_clean();
229
227
  for ($i = count($layoutsToInclude) - 1; $i >= 0; $i--) {
230
228
  $layoutPath = $layoutsToInclude[$i];
@@ -233,7 +231,9 @@ try {
233
231
  $childContent = ob_get_clean();
234
232
  }
235
233
 
236
- require_once $contentToInclude;
234
+ if ($isParentLayout) {
235
+ require_once $contentToInclude;
236
+ }
237
237
  $content = $childContent;
238
238
  } else {
239
239
  require_once 'not-found.php';
@@ -241,5 +241,6 @@ try {
241
241
  }
242
242
  $content .= ob_get_clean();
243
243
  } catch (Throwable $e) {
244
- echo "<div class='error'>An error occurred: " . $e->getMessage() . "</div>";
244
+ echo "<div class='error'>An error occurred: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</div>";
245
+ $content .= ob_get_clean();
245
246
  }
@@ -1,5 +1,4 @@
1
1
  <div class="flex flex-col min-h-[100vh]">
2
- <?php $relativePath; ?>
3
2
  <header class="px-4 lg:px-6 h-14 flex items-center">
4
3
  <a class="flex items-center justify-center" href="#">
5
4
  <img class="h-10 w-10" src="<?= $baseUrl ?>assets/images/prisma-php.png" alt="Prisma PHP">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.8.18",
3
+ "version": "1.8.20",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",