create-prisma-php-app 1.22.3 → 1.22.4

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.
Files changed (2) hide show
  1. package/dist/bootstrap.php +16 -11
  2. package/package.json +1 -1
@@ -188,29 +188,37 @@ function dynamicRoute($uri)
188
188
  $normalizedUri = ltrim(str_replace('\\', '/', $uri), './');
189
189
  $normalizedUriEdited = "src/app/$normalizedUri";
190
190
  $uriSegments = explode('/', $normalizedUriEdited);
191
+
191
192
  foreach ($_filesListRoutes as $route) {
192
193
  $normalizedRoute = trim(str_replace('\\', '/', $route), '.');
194
+
195
+ // Skip non-.php files to improve performance
196
+ if (pathinfo($normalizedRoute, PATHINFO_EXTENSION) !== 'php') {
197
+ continue;
198
+ }
199
+
193
200
  $routeSegments = explode('/', ltrim($normalizedRoute, '/'));
194
201
 
195
202
  $filteredRouteSegments = array_values(array_filter($routeSegments, function ($segment) {
196
203
  return !preg_match('/\(.+\)/', $segment); // Skip segments with parentheses (groups)
197
204
  }));
198
205
 
199
- $singleDynamic = preg_match_all('/\[[^\]]+\]/', $normalizedRoute, $matches) === 1 && !strpos($normalizedRoute, '[...');
206
+ $singleDynamic = preg_match_all('/\[[^\]]+\]/', $normalizedRoute, $matches) === 1 && strpos($normalizedRoute, '[...') === false;
207
+
200
208
  if ($singleDynamic) {
201
209
  $segmentMatch = singleDynamicRoute($uriSegments, $filteredRouteSegments);
202
210
  $index = array_search($segmentMatch, $filteredRouteSegments);
211
+
203
212
  if ($index !== false && isset($uriSegments[$index])) {
204
213
  $trimSegmentMatch = trim($segmentMatch, '[]');
205
214
  $dynamicRouteParams = new \ArrayObject([$trimSegmentMatch => $uriSegments[$index]], \ArrayObject::ARRAY_AS_PROPS);
215
+
206
216
  $dynamicRouteUri = str_replace($segmentMatch, $uriSegments[$index], $normalizedRoute);
207
217
  $dynamicRouteUri = preg_replace('/\(.+\)/', '', $dynamicRouteUri);
208
218
  $dynamicRouteUri = preg_replace('/\/+/', '/', $dynamicRouteUri);
209
- $dynamicRouteUriDirname = dirname($dynamicRouteUri);
210
- $dynamicRouteUriDirname = rtrim($dynamicRouteUriDirname, '/');
219
+ $dynamicRouteUriDirname = rtrim(dirname($dynamicRouteUri), '/');
211
220
 
212
- $expectedUri = '/src/app/' . $normalizedUri;
213
- $expectedUri = rtrim($expectedUri, '/');
221
+ $expectedUri = rtrim('/src/app/' . $normalizedUri, '/');
214
222
 
215
223
  if (strpos($normalizedRoute, 'route.php') !== false || strpos($normalizedRoute, 'index.php') !== false) {
216
224
  if ($expectedUri === $dynamicRouteUriDirname) {
@@ -221,9 +229,9 @@ function dynamicRoute($uri)
221
229
  }
222
230
  } elseif (strpos($normalizedRoute, '[...') !== false) {
223
231
  // Clean and normalize the route
224
- $cleanedNormalizedRoute = preg_replace('/\(.+\)/', '', $normalizedRoute); // Remove any public/private segment
225
- $cleanedNormalizedRoute = preg_replace('/\/+/', '/', $cleanedNormalizedRoute); // Replace multiple slashes
226
- $dynamicSegmentRoute = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedNormalizedRoute); // Remove the dynamic segment
232
+ $cleanedNormalizedRoute = preg_replace('/\(.+\)/', '', $normalizedRoute);
233
+ $cleanedNormalizedRoute = preg_replace('/\/+/', '/', $cleanedNormalizedRoute);
234
+ $dynamicSegmentRoute = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedNormalizedRoute);
227
235
 
228
236
  // Check if the normalized URI starts with the cleaned route
229
237
  if (strpos("/src/app/$normalizedUri", $dynamicSegmentRoute) === 0) {
@@ -364,7 +372,6 @@ function checkForDuplicateRoutes()
364
372
  }
365
373
  }
366
374
 
367
-
368
375
  function containsChildContent($filePath)
369
376
  {
370
377
  $fileContent = file_get_contents($filePath);
@@ -536,8 +543,6 @@ function getLoadingsFiles()
536
543
  return '';
537
544
  }
538
545
 
539
-
540
-
541
546
  function getPrismaSettings(): \ArrayObject
542
547
  {
543
548
  $_prismaPHPSettingsFile = DOCUMENT_PATH . '/prisma-php.json';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.22.3",
3
+ "version": "1.22.4",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",