create-prisma-php-app 1.20.519 → 1.20.521
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.
- package/dist/.htaccess +1 -1
- package/dist/bootstrap.php +78 -41
- package/dist/index.js +14 -7
- package/dist/prisma-client-php/index.enc +1 -1
- package/dist/prisma-client-php/index.js +6 -2
- package/dist/settings/public-functions.php +29 -0
- package/dist/settings/swagger-setup.js +17 -4
- package/dist/src/Lib/Auth/Auth.php +38 -6
- package/dist/src/Lib/StateManager.php +9 -0
- package/dist/src/app/route.php +2 -1
- package/dist/src/app/swagger-docs/apis/pphp-swagger.json +25 -25
- package/package.json +1 -1
package/dist/.htaccess
CHANGED
|
@@ -15,7 +15,7 @@ RewriteEngine On
|
|
|
15
15
|
</IfModule>
|
|
16
16
|
|
|
17
17
|
# Exclude static files from being redirected
|
|
18
|
-
RewriteCond %{REQUEST_URI} !\.(css|js|png|
|
|
18
|
+
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpe?g|gif|svg|webp|woff2?|ttf|eot|ico|pdf|mp4|webm|mp3|ogg)$ [NC]
|
|
19
19
|
RewriteCond %{REQUEST_URI} !^/bootstrap.php
|
|
20
20
|
RewriteRule ^(.*)$ bootstrap.php [QSA,L]
|
|
21
21
|
|
package/dist/bootstrap.php
CHANGED
|
@@ -8,6 +8,7 @@ require_once __DIR__ . '/vendor/autoload.php';
|
|
|
8
8
|
require_once __DIR__ . '/settings/paths.php';
|
|
9
9
|
|
|
10
10
|
use Lib\Middleware\AuthMiddleware;
|
|
11
|
+
use Lib\Auth\Auth;
|
|
11
12
|
use Dotenv\Dotenv;
|
|
12
13
|
|
|
13
14
|
$dotenv = Dotenv::createImmutable(\DOCUMENT_PATH);
|
|
@@ -136,8 +137,9 @@ function getFilePrecedence()
|
|
|
136
137
|
|
|
137
138
|
function uriExtractor(string $scriptUrl): string
|
|
138
139
|
{
|
|
139
|
-
$
|
|
140
|
-
|
|
140
|
+
global $_prismaPHPSettings;
|
|
141
|
+
|
|
142
|
+
$projectName = $_prismaPHPSettings['projectName'] ?? '';
|
|
141
143
|
if (empty($projectName)) {
|
|
142
144
|
return "/";
|
|
143
145
|
}
|
|
@@ -383,44 +385,6 @@ function setupErrorHandling(&$content)
|
|
|
383
385
|
});
|
|
384
386
|
}
|
|
385
387
|
|
|
386
|
-
ob_start();
|
|
387
|
-
require_once SETTINGS_PATH . '/public-functions.php';
|
|
388
|
-
require_once SETTINGS_PATH . '/request-methods.php';
|
|
389
|
-
$_metadataFile = APP_PATH . '/metadata.php';
|
|
390
|
-
$_metadataArray = file_exists($_metadataFile) ? require_once $_metadataFile : [];
|
|
391
|
-
$_filesListRoutes = [];
|
|
392
|
-
/**
|
|
393
|
-
* @var array $metadata Metadata information
|
|
394
|
-
*/
|
|
395
|
-
$metadata = [];
|
|
396
|
-
/**
|
|
397
|
-
* @var string $uri The URI of the current request
|
|
398
|
-
*/
|
|
399
|
-
$uri = "";
|
|
400
|
-
/**
|
|
401
|
-
* @var string $pathname The pathname of the current request
|
|
402
|
-
*/
|
|
403
|
-
$pathname = "";
|
|
404
|
-
/**
|
|
405
|
-
* @var array $dynamicRouteParams The dynamic route parameters
|
|
406
|
-
*/
|
|
407
|
-
$dynamicRouteParams = [];
|
|
408
|
-
/**
|
|
409
|
-
* @var string $content The content to be included in the main layout file
|
|
410
|
-
*/
|
|
411
|
-
$content = "";
|
|
412
|
-
/**
|
|
413
|
-
* @var string $childContent The child content to be included in the layout file
|
|
414
|
-
*/
|
|
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 = [];
|
|
424
388
|
|
|
425
389
|
function containsChildContent($filePath)
|
|
426
390
|
{
|
|
@@ -615,6 +579,76 @@ function getLoadingsFiles()
|
|
|
615
579
|
return '';
|
|
616
580
|
}
|
|
617
581
|
|
|
582
|
+
function authenticateUserToken()
|
|
583
|
+
{
|
|
584
|
+
$token = getBearerToken();
|
|
585
|
+
if ($token) {
|
|
586
|
+
$auth = Auth::getInstance();
|
|
587
|
+
$verifyToken = $auth->verifyToken($token);
|
|
588
|
+
if ($verifyToken) {
|
|
589
|
+
$auth->authenticate($verifyToken);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function getPrismaSettings(): \ArrayObject
|
|
595
|
+
{
|
|
596
|
+
$_prismaPHPSettingsFile = DOCUMENT_PATH . '/prisma-php.json';
|
|
597
|
+
|
|
598
|
+
if (file_exists($_prismaPHPSettingsFile)) {
|
|
599
|
+
$jsonContent = file_get_contents($_prismaPHPSettingsFile);
|
|
600
|
+
$decodedJson = json_decode($jsonContent, true);
|
|
601
|
+
|
|
602
|
+
if (json_last_error() === JSON_ERROR_NONE) {
|
|
603
|
+
return new \ArrayObject($decodedJson, \ArrayObject::ARRAY_AS_PROPS);
|
|
604
|
+
} else {
|
|
605
|
+
return new \ArrayObject([]);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
ob_start();
|
|
611
|
+
require_once SETTINGS_PATH . '/public-functions.php';
|
|
612
|
+
require_once SETTINGS_PATH . '/request-methods.php';
|
|
613
|
+
$_metadataFile = APP_PATH . '/metadata.php';
|
|
614
|
+
$_metadataArray = file_exists($_metadataFile) ? require_once $_metadataFile : [];
|
|
615
|
+
$_filesListRoutes = [];
|
|
616
|
+
$_prismaPHPSettings = getPrismaSettings();
|
|
617
|
+
$_fileToInclude = '';
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @var array $metadata Metadata information
|
|
621
|
+
*/
|
|
622
|
+
$metadata = [];
|
|
623
|
+
/**
|
|
624
|
+
* @var string $uri The URI of the current request
|
|
625
|
+
*/
|
|
626
|
+
$uri = "";
|
|
627
|
+
/**
|
|
628
|
+
* @var string $pathname The pathname of the current request
|
|
629
|
+
*/
|
|
630
|
+
$pathname = "";
|
|
631
|
+
/**
|
|
632
|
+
* @var array $dynamicRouteParams The dynamic route parameters
|
|
633
|
+
*/
|
|
634
|
+
$dynamicRouteParams = [];
|
|
635
|
+
/**
|
|
636
|
+
* @var string $content The content to be included in the main layout file
|
|
637
|
+
*/
|
|
638
|
+
$content = "";
|
|
639
|
+
/**
|
|
640
|
+
* @var string $childContent The child content to be included in the layout file
|
|
641
|
+
*/
|
|
642
|
+
$childContent = "";
|
|
643
|
+
/**
|
|
644
|
+
* @var array $mainLayoutHead The head content to be included in the main layout file
|
|
645
|
+
*/
|
|
646
|
+
$mainLayoutHead = [];
|
|
647
|
+
/**
|
|
648
|
+
* @var array $mainLayoutFooter The footer content to be included in the main layout file
|
|
649
|
+
*/
|
|
650
|
+
$mainLayoutFooter = [];
|
|
651
|
+
|
|
618
652
|
try {
|
|
619
653
|
$_determineContentToInclude = determineContentToInclude();
|
|
620
654
|
checkForDuplicateRoutes();
|
|
@@ -622,6 +656,9 @@ try {
|
|
|
622
656
|
$_layoutsToInclude = $_determineContentToInclude['layouts'] ?? [];
|
|
623
657
|
$uri = $_determineContentToInclude['uri'] ?? '';
|
|
624
658
|
$pathname = $uri ? "/" . $uri : "/";
|
|
659
|
+
$_fileToInclude = basename($_contentToInclude);
|
|
660
|
+
|
|
661
|
+
authenticateUserToken();
|
|
625
662
|
|
|
626
663
|
if (empty($_contentToInclude)) {
|
|
627
664
|
if (!$isXFilRequest) {
|
|
@@ -652,7 +689,7 @@ try {
|
|
|
652
689
|
header('Content-Type: application/json');
|
|
653
690
|
echo json_encode([
|
|
654
691
|
'success' => false,
|
|
655
|
-
'error' => '
|
|
692
|
+
'error' => 'Not found'
|
|
656
693
|
]);
|
|
657
694
|
http_response_code(404); // Set HTTP status code to 404 Not Found
|
|
658
695
|
}
|
package/dist/index.js
CHANGED
|
@@ -343,18 +343,25 @@ function modifyLayoutPHP(baseDir, answer) {
|
|
|
343
343
|
if (checkExcludeFiles(layoutPath)) return;
|
|
344
344
|
try {
|
|
345
345
|
let indexContent = fs.readFileSync(layoutPath, "utf8");
|
|
346
|
-
|
|
346
|
+
let stylesAndLinks = "";
|
|
347
|
+
if (!answer.backendOnly) {
|
|
348
|
+
stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>/css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>/js/index.js"></script>`;
|
|
349
|
+
}
|
|
347
350
|
// Tailwind CSS link or CDN script
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
let tailwindLink = "";
|
|
352
|
+
if (!answer.backendOnly) {
|
|
353
|
+
tailwindLink = answer.tailwindcss
|
|
354
|
+
? ` <link href="<?php echo $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
|
|
355
|
+
: ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
|
|
356
|
+
}
|
|
351
357
|
// Insert before the closing </head> tag
|
|
358
|
+
const breakLine = tailwindLink.length > 0 ? "\n" : "";
|
|
352
359
|
indexContent = indexContent.replace(
|
|
353
360
|
"</head>",
|
|
354
|
-
`${tailwindLink}
|
|
355
|
-
<?php echo implode("\\n", $mainLayoutHead);
|
|
361
|
+
`${tailwindLink}${breakLine} <!-- Dynamic Head -->
|
|
362
|
+
<?php echo implode("\\n", $mainLayoutHead); ?>
|
|
363
|
+
</head>`
|
|
356
364
|
);
|
|
357
|
-
console.log("🚀 ~ modifyLayoutPHP ~ indexContent:", indexContent);
|
|
358
365
|
fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
|
|
359
366
|
console.log(
|
|
360
367
|
chalk.green(
|