create-prisma-php-app 1.26.539 → 1.26.540
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/bootstrap.php
CHANGED
|
@@ -15,7 +15,6 @@ use Lib\Middleware\AuthMiddleware;
|
|
|
15
15
|
use Lib\Auth\Auth;
|
|
16
16
|
use Lib\MainLayout;
|
|
17
17
|
use Lib\PHPX\TemplateCompiler;
|
|
18
|
-
use Lib\PHPX\IPHPX;
|
|
19
18
|
|
|
20
19
|
$dotenv = Dotenv::createImmutable(\DOCUMENT_PATH);
|
|
21
20
|
$dotenv->load();
|
|
@@ -706,55 +705,6 @@ register_shutdown_function(function () {
|
|
|
706
705
|
}
|
|
707
706
|
});
|
|
708
707
|
|
|
709
|
-
spl_autoload_register(
|
|
710
|
-
function ($class) {
|
|
711
|
-
// Path to the log file
|
|
712
|
-
$logFile = SETTINGS_PATH . "/class-log.json";
|
|
713
|
-
|
|
714
|
-
// Ensure the log file exists
|
|
715
|
-
if (!file_exists($logFile)) {
|
|
716
|
-
file_put_contents($logFile, json_encode([]));
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
// Read the existing log data
|
|
720
|
-
$logData = json_decode(file_get_contents($logFile), true) ?? [];
|
|
721
|
-
|
|
722
|
-
// Determine the file path for the class
|
|
723
|
-
$classParts = explode('\\', $class);
|
|
724
|
-
$filePath = __DIR__ . '/src/' . implode('/', $classParts) . '.php';
|
|
725
|
-
|
|
726
|
-
// Attempt to load the file
|
|
727
|
-
if (file_exists($filePath)) {
|
|
728
|
-
// Track previously declared classes
|
|
729
|
-
$previousClasses = get_declared_classes();
|
|
730
|
-
|
|
731
|
-
// Require the file
|
|
732
|
-
require_once $filePath;
|
|
733
|
-
|
|
734
|
-
// Find newly declared classes
|
|
735
|
-
$newClasses = array_diff(get_declared_classes(), $previousClasses);
|
|
736
|
-
|
|
737
|
-
// Process all new classes from the file
|
|
738
|
-
foreach ($newClasses as $newClass) {
|
|
739
|
-
$reflectionClass = new ReflectionClass($newClass);
|
|
740
|
-
|
|
741
|
-
// Check if the class implements IPHPX
|
|
742
|
-
if ($reflectionClass->implementsInterface(IPHPX::class)) {
|
|
743
|
-
$logData[$newClass] = [
|
|
744
|
-
'class_name' => $newClass,
|
|
745
|
-
'file_path' => $filePath,
|
|
746
|
-
];
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// Save back to the JSON file
|
|
752
|
-
file_put_contents($logFile, json_encode($logData, JSON_PRETTY_PRINT));
|
|
753
|
-
},
|
|
754
|
-
true,
|
|
755
|
-
true
|
|
756
|
-
);
|
|
757
|
-
|
|
758
708
|
try {
|
|
759
709
|
$_determineContentToInclude = determineContentToInclude();
|
|
760
710
|
$_contentToInclude = $_determineContentToInclude['path'] ?? '';
|
|
@@ -7,7 +7,7 @@ const { __dirname } = getFileMeta();
|
|
|
7
7
|
|
|
8
8
|
const parser = new Engine({
|
|
9
9
|
parser: {
|
|
10
|
-
|
|
10
|
+
php8: true,
|
|
11
11
|
extractDoc: true,
|
|
12
12
|
},
|
|
13
13
|
ast: {
|
|
@@ -29,7 +29,9 @@ async function loadImportsData(): Promise<Record<string, string>> {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function saveImportsData(
|
|
32
|
+
async function saveImportsData(
|
|
33
|
+
data: Record<string, { className: string; filePath: string }>
|
|
34
|
+
) {
|
|
33
35
|
await fs.writeFile(IMPORTS_FILE, JSON.stringify(data, null, 2), "utf-8");
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -148,11 +150,17 @@ export async function updateComponentImports() {
|
|
|
148
150
|
// Now filter using class-log.json
|
|
149
151
|
const classLog = await loadClassLogData();
|
|
150
152
|
|
|
151
|
-
const filteredImports: Record<
|
|
153
|
+
const filteredImports: Record<
|
|
154
|
+
string,
|
|
155
|
+
{ className: string; filePath: string }
|
|
156
|
+
> = {};
|
|
152
157
|
for (const [alias, fqn] of Object.entries(allImports)) {
|
|
153
158
|
if (classLog[fqn]) {
|
|
154
159
|
// console.log(`Including: ${alias} -> ${fqn}`);
|
|
155
|
-
filteredImports[alias] =
|
|
160
|
+
filteredImports[alias] = {
|
|
161
|
+
className: fqn,
|
|
162
|
+
filePath: classLog[fqn].filePath,
|
|
163
|
+
};
|
|
156
164
|
} else {
|
|
157
165
|
// console.log(`Excluding: ${alias} -> ${fqn}`);
|
|
158
166
|
}
|
|
@@ -12,7 +12,7 @@ const PHPX_BASE_CLASS = "PHPX";
|
|
|
12
12
|
|
|
13
13
|
const parser = new Engine({
|
|
14
14
|
parser: {
|
|
15
|
-
|
|
15
|
+
php8: true,
|
|
16
16
|
extractDoc: true,
|
|
17
17
|
},
|
|
18
18
|
ast: {
|
|
@@ -113,8 +113,12 @@ async function updateClassLogForFile(
|
|
|
113
113
|
for (const cls of classes) {
|
|
114
114
|
if (cls.implementsIPHPX || cls.extendsPHPX) {
|
|
115
115
|
const classFullName = await guessFullClassName(filePath, cls.name);
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const relativePath = path
|
|
117
|
+
.relative(SRC_DIR, filePath)
|
|
118
|
+
.replace(/\\/g, "\\");
|
|
119
|
+
logData[classFullName] = {
|
|
120
|
+
filePath: relativePath,
|
|
121
|
+
};
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
}
|
|
@@ -161,26 +161,34 @@ class TemplateCompiler
|
|
|
161
161
|
array $attributes,
|
|
162
162
|
string $innerContent
|
|
163
163
|
): string {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
$
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
}
|
|
164
|
+
if (isset(self::$classMappings[$componentName])) {
|
|
165
|
+
$classMapping = self::$classMappings[$componentName];
|
|
166
|
+
|
|
167
|
+
// Ensure the required file is included
|
|
168
|
+
require_once str_replace('\\', '/', SRC_PATH . '/' . $classMapping['filePath']);
|
|
169
|
+
|
|
170
|
+
// Use the fully qualified class name
|
|
171
|
+
$className = $classMapping['className'];
|
|
172
|
+
|
|
173
|
+
// Check if the class exists
|
|
174
|
+
if (class_exists($className)) {
|
|
175
|
+
// Instantiate the component
|
|
176
|
+
$componentInstance = new $className($attributes);
|
|
177
|
+
|
|
178
|
+
// Render the component
|
|
179
|
+
$renderedContent = $componentInstance->render();
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
// Check if the rendered content contains other components
|
|
182
|
+
if (strpos($renderedContent, '<') !== false) {
|
|
183
|
+
// Re-parse the rendered content
|
|
184
|
+
return self::compile($renderedContent);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Return the plain rendered content if no components are detected
|
|
188
|
+
return $renderedContent;
|
|
189
|
+
} else {
|
|
190
|
+
throw new \RuntimeException("Class $className does not exist.");
|
|
191
|
+
}
|
|
184
192
|
} else {
|
|
185
193
|
// Render as an HTML tag
|
|
186
194
|
$attributesString = self::renderAttributes($attributes);
|