create-prisma-php-app 1.20.516 → 1.20.517

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.
@@ -386,15 +386,41 @@ function setupErrorHandling(&$content)
386
386
  ob_start();
387
387
  require_once SETTINGS_PATH . '/public-functions.php';
388
388
  require_once SETTINGS_PATH . '/request-methods.php';
389
- $metadataFile = APP_PATH . '/metadata.php';
390
- $_metadataArray = file_exists($metadataFile) ? require_once $metadataFile : [];
389
+ $_metadataFile = APP_PATH . '/metadata.php';
390
+ $_metadataArray = file_exists($_metadataFile) ? require_once $_metadataFile : [];
391
391
  $_filesListRoutes = [];
392
- $metadata = "";
392
+ /**
393
+ * @var array $metadata Metadata information
394
+ */
395
+ $metadata = [];
396
+ /**
397
+ * @var string $uri The URI of the current request
398
+ */
393
399
  $uri = "";
400
+ /**
401
+ * @var string $pathname The pathname of the current request
402
+ */
394
403
  $pathname = "";
404
+ /**
405
+ * @var array $dynamicRouteParams The dynamic route parameters
406
+ */
395
407
  $dynamicRouteParams = [];
408
+ /**
409
+ * @var string $content The content to be included in the main layout file
410
+ */
396
411
  $content = "";
412
+ /**
413
+ * @var string $childContent The child content to be included in the layout file
414
+ */
397
415
  $childContent = "";
416
+ /**
417
+ * @var array $mainLayoutHead The head content to be included in the main layout file
418
+ */
419
+ $mainLayoutHead = [];
420
+ /**
421
+ * @var array $mainLayoutFooter The footer content to be included in the main layout file
422
+ */
423
+ $mainLayoutFooter = [];
398
424
 
399
425
  function containsChildContent($filePath)
400
426
  {
@@ -639,7 +665,7 @@ try {
639
665
  exit;
640
666
  }
641
667
 
642
- $metadata = $_metadataArray[$uri] ?? ($_metadataArray['default'] ?? null);
668
+ $metadata = $_metadataArray[$uri] ?? ($_metadataArray['default'] ?? []);
643
669
  $_parentLayoutPath = APP_PATH . '/layout.php';
644
670
  $_isParentLayout = !empty($_layoutsToInclude) && strpos($_layoutsToInclude[0], 'src/app/layout.php') !== false;
645
671
 
package/dist/index.js CHANGED
@@ -352,7 +352,7 @@ function modifyLayoutPHP(baseDir, answer) {
352
352
  indexContent = indexContent.replace(
353
353
  "</head>",
354
354
  `${tailwindLink}\n <!-- Dynamic Head -->\n
355
- <?php echo implode("\n", $mainLayoutHead); ?></head>`
355
+ <?php echo implode("\\n", $mainLayoutHead); ?></head>`
356
356
  );
357
357
  fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
358
358
  console.log(
@@ -1,10 +1,30 @@
1
1
  <?php
2
2
 
3
- // Absolute path
3
+ /**
4
+ * @var string SETTINGS_PATH - The absolute path to the settings directory
5
+ */
4
6
  define("SETTINGS_PATH", dirname(__FILE__));
7
+ /**
8
+ * @var string PUBLIC_PATH - The absolute path to the public directory
9
+ */
5
10
  define("PUBLIC_PATH", dirname(SETTINGS_PATH) . "/public");
11
+ /**
12
+ * @var string PRISMA_LIB_PATH - The absolute path to the Prisma library directory
13
+ */
6
14
  define("PRISMA_LIB_PATH", dirname(SETTINGS_PATH) . "/src/Lib/Prisma");
15
+ /**
16
+ * @var string SRC_PATH - The absolute path to the src directory
17
+ */
7
18
  define("SRC_PATH", dirname(SETTINGS_PATH) . "/src");
19
+ /**
20
+ * @var string APP_PATH - The absolute path to the app directory
21
+ */
8
22
  define("APP_PATH", dirname(SETTINGS_PATH) . "/src/app");
23
+ /**
24
+ * @var string LIB_PATH - The absolute path to the layout directory
25
+ */
9
26
  define("LIB_PATH", dirname(SETTINGS_PATH) . "/src/Lib");
27
+ /**
28
+ * @var string DOCUMENT_PATH - The absolute path to the layout directory
29
+ */
10
30
  define("DOCUMENT_PATH", dirname(SETTINGS_PATH));
@@ -1,5 +1,8 @@
1
1
  <?php
2
2
 
3
+ /**
4
+ * @var string $requestMethod - The request method.
5
+ */
3
6
  $requestMethod = $_SERVER['REQUEST_METHOD'];
4
7
 
5
8
  if ($requestMethod == 'OPTIONS') {
@@ -7,6 +10,9 @@ if ($requestMethod == 'OPTIONS') {
7
10
  exit;
8
11
  }
9
12
 
13
+ /**
14
+ * @var array $allowedMethods - The allowed request methods.
15
+ */
10
16
  $allowedMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
11
17
 
12
18
  if (!in_array($requestMethod, $allowedMethods)) {
@@ -15,27 +21,83 @@ if (!in_array($requestMethod, $allowedMethods)) {
15
21
  exit;
16
22
  }
17
23
 
24
+ /**
25
+ * @var bool $isGet - True if the request method is GET, false otherwise.
26
+ */
18
27
  $isGet = $requestMethod === 'GET';
28
+ /**
29
+ * @var bool $isPost - True if the request method is POST, false otherwise.
30
+ */
19
31
  $isPost = $requestMethod === 'POST';
32
+ /**
33
+ * @var bool $isPut - True if the request method is PUT, false otherwise.
34
+ */
20
35
  $isPut = $requestMethod === 'PUT';
36
+ /**
37
+ * @var bool $isDelete - True if the request method is DELETE, false otherwise.
38
+ */
21
39
  $isDelete = $requestMethod === 'DELETE';
40
+ /**
41
+ * @var bool $isPatch - True if the request method is PATCH, false otherwise.
42
+ */
22
43
  $isPatch = $requestMethod === 'PATCH';
44
+ /**
45
+ * @var bool $isHead - True if the request method is HEAD, false otherwise.
46
+ */
23
47
  $isHead = $requestMethod === 'HEAD';
48
+ /**
49
+ * @var bool $isOptions - True if the request method is OPTIONS, false otherwise.
50
+ */
24
51
  $isOptions = $requestMethod === 'OPTIONS';
52
+ /**
53
+ * @var bool $isAjax - True if the request is an AJAX request, false otherwise.
54
+ */
25
55
  $isAjax = isAjaxRequest();
56
+ /**
57
+ * @var bool $isWire - True if the request is a wire request, false otherwise.
58
+ */
26
59
  $isWire = isWireRequest();
60
+ /**
61
+ * @var bool $isXFilRequest - True if the request is an X-Fil request, false otherwise.
62
+ */
27
63
  $isXFilRequest = isXFilRequest();
64
+ /**
65
+ * @var string $contentType - The content type of the request.
66
+ */
28
67
  $contentType = $_SERVER['CONTENT_TYPE'] ?? '';
68
+ /**
69
+ * @var string $requestedWith - The X-Requested-With header of the request.
70
+ */
29
71
  $requestedWith = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '';
72
+ /**
73
+ * @var string $protocol - The protocol of the request.
74
+ */
30
75
  $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
31
76
  (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ||
32
77
  $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
78
+ /**
79
+ * @var string $domainName - The domain name of the request.
80
+ */
33
81
  $domainName = $_SERVER['HTTP_HOST'];
34
- $scriptName = dirname($_SERVER['SCRIPT_NAME']) . '/';
35
- $baseUrl = $protocol . $domainName . rtrim($scriptName, '/') . '/src/app';
36
- $documentUrl = $protocol . $domainName . rtrim($scriptName, '/');
82
+ /**
83
+ * @var string $scriptName - The script name of the request.
84
+ */
85
+ $scriptName = dirname($_SERVER['SCRIPT_NAME']);
86
+ /**
87
+ * @var string $baseUrl - The base URL of the request.
88
+ */
89
+ $baseUrl = $protocol . $domainName . "$scriptName/src/app";
90
+ /**
91
+ * @var string $documentUrl - The document URL of the request.
92
+ */
93
+ $documentUrl = $protocol . $domainName . $scriptName;
94
+ /**
95
+ * @var string $referer - The referer of the request.
96
+ */
37
97
  $referer = $_SERVER['HTTP_REFERER'] ?? 'Unknown';
38
-
98
+ /**
99
+ * @var \ArrayObject $params - The request parameters
100
+ */
39
101
  $params = [];
40
102
 
41
103
  if ($requestMethod == 'GET') {
@@ -1,7 +1,7 @@
1
1
  <div class="flex flex-col min-h-[100vh] bg-gradient-to-b from-[#a1b8c2] to-white dark:from-[#334455] dark:to-black">
2
2
  <header class="px-4 lg:px-6 h-14 flex items-center">
3
3
  <a class="flex items-center justify-center" href="/">
4
- <img class="h-10 w-10" src="<?= $baseUrl ?>assets/images/prisma-php.png" alt="Prisma PHP">
4
+ <img class="h-10 w-10" src="<?php echo $baseUrl ?>/assets/images/prisma-php.png" alt="Prisma PHP">
5
5
  <span class="sr-only">Prisma PHP</span>
6
6
  </a>
7
7
  <nav class="ml-auto flex gap-4 sm:gap-6">
@@ -24,7 +24,7 @@
24
24
  <div class="px-4 md:px-6">
25
25
  <div class="flex flex-col items-center space-y-4 text-center">
26
26
  <h1 class="text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl lg:text-6xl/none flex items-center gap-3 justify-center">
27
- Welcome to Prisma PHP <img class="h-20 w-20 hidden sm:block" src="<?= $baseUrl ?>assets/images/prisma-php.png" alt="Prisma PHP">
27
+ Welcome to Prisma PHP <img class="h-20 w-20 hidden sm:block" src="<?php echo $baseUrl ?>/assets/images/prisma-php.png" alt="Prisma PHP">
28
28
  </h1>
29
29
  <p class="mx-auto max-w-[700px] text-gray-500 md:text-xl dark:text-gray-400">
30
30
  The Next Generation ORM for PHP
@@ -1,4 +1,15 @@
1
+ <?php
2
+
3
+ $mainLayoutHead = [
4
+ "<link rel='stylesheet' type='text/css' href='$baseUrl/swagger-docs/dist/swagger-ui.css' />",
5
+ "<link rel='stylesheet' type='text/css' href='$baseUrl/swagger-docs/dist/index.css' />",
6
+ "<link rel='icon' type='image/png' href='$baseUrl/swagger-docs/dist/favicon-32x32.png' sizes='32x32' />",
7
+ "<link rel='icon' type='image/png' href='$baseUrl/swagger-docs/dist/favicon-16x16.png' sizes='16x16' />",
8
+ ]
9
+
10
+ ?>
11
+
1
12
  <div id="swagger-ui"></div>
2
- <script src="<?= $baseUrl ?>swagger-docs/dist/swagger-ui-bundle.js" charset="UTF-8"> </script>
3
- <script src="<?= $baseUrl ?>swagger-docs/dist/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
4
- <script src="<?= $baseUrl ?>swagger-docs/dist/swagger-initializer.js" charset="UTF-8"> </script>
13
+ <script src="<?php echo $baseUrl ?>/swagger-docs/dist/swagger-ui-bundle.js" charset="UTF-8"> </script>
14
+ <script src="<?php echo $baseUrl ?>/swagger-docs/dist/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
15
+ <script src="<?php echo $baseUrl ?>/swagger-docs/dist/swagger-initializer.js" charset="UTF-8"> </script>
@@ -4,14 +4,16 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <title>Swagger UI</title>
7
- <link rel="stylesheet" type="text/css" href="<?= $baseUrl ?>swagger-docs/dist/swagger-ui.css" />
8
- <link rel="stylesheet" type="text/css" href="<?= $baseUrl ?>swagger-docs/dist/index.css" />
9
- <link rel="icon" type="image/png" href="<?= $baseUrl ?>swagger-docs/dist/favicon-32x32.png" sizes="32x32" />
10
- <link rel="icon" type="image/png" href="<?= $baseUrl ?>swagger-docs/dist/favicon-16x16.png" sizes="16x16" />
7
+ <link rel="stylesheet" type="text/css" href="<?php echo $baseUrl ?>/swagger-docs/dist/swagger-ui.css" />
8
+ <link rel="stylesheet" type="text/css" href="<?php echo $baseUrl ?>/swagger-docs/dist/index.css" />
9
+ <link rel="icon" type="image/png" href="<?php echo $baseUrl ?>/swagger-docs/dist/favicon-32x32.png" sizes="32x32" />
10
+ <link rel="icon" type="image/png" href="<?php echo $baseUrl ?>/swagger-docs/dist/favicon-16x16.png" sizes="16x16" />
11
11
  </head>
12
12
 
13
13
  <body>
14
14
  <?php echo $content; ?>
15
+ <!-- Dynamic Footer -->
16
+ <?php echo implode("\n", $mainLayoutFooter); ?>
15
17
  </body>
16
18
 
17
19
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.20.516",
3
+ "version": "1.20.517",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",