create-prisma-php-app 1.1.0 → 1.1.1
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/src/app/api/api.php
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
namespace App\Api;
|
|
4
4
|
|
|
5
|
+
require_once __DIR__ . "/../../../bootstrap.php";
|
|
6
|
+
|
|
5
7
|
use App\Classes\Prisma\Prisma;
|
|
6
8
|
|
|
7
9
|
if (!empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") {
|
|
@@ -24,16 +26,36 @@ if (!empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
$prisma = new Prisma();
|
|
29
|
+
// Ensure that we correctly handle the case where $className might not directly map to a property.
|
|
30
|
+
if (!property_exists($prisma, $className)) {
|
|
31
|
+
echo "Error: Property $className not found in Prisma class!";
|
|
32
|
+
exit;
|
|
33
|
+
}
|
|
27
34
|
$instance = $prisma->$className;
|
|
35
|
+
|
|
28
36
|
if (!method_exists($instance, $methodName)) {
|
|
29
37
|
echo "Error: Method $methodName not found in class $fullClassName!";
|
|
30
38
|
exit;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
// Check if $params is correctly structured for the expected arguments.
|
|
42
|
+
// Adjust the logic here based on how $params should be passed to the method.
|
|
43
|
+
// This example assumes $methodName expects an array of arguments.
|
|
44
|
+
if (is_array($params)) {
|
|
45
|
+
// Attempt to call the method with unpacked arguments.
|
|
46
|
+
try {
|
|
47
|
+
$result = $instance->$methodName($params);
|
|
48
|
+
if (is_object($result)) {
|
|
49
|
+
$result = (array) $result;
|
|
50
|
+
}
|
|
51
|
+
echo json_encode($result, JSON_INVALID_UTF8_IGNORE);
|
|
52
|
+
} catch (\ArgumentCountError $e) {
|
|
53
|
+
echo "Error: Incorrect number of arguments provided for $methodName method.";
|
|
54
|
+
} catch (\Exception $e) {
|
|
55
|
+
// Handle other potential errors here.
|
|
56
|
+
echo "Error: An error occurred while executing $methodName method. " . $e->getMessage();
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
echo "Error: Parameters for $methodName method are not correctly formatted or missing.";
|
|
36
60
|
}
|
|
37
|
-
|
|
38
|
-
echo json_encode($result, JSON_INVALID_UTF8_IGNORE);
|
|
39
61
|
}
|
package/package.json
CHANGED