prisma-php 0.0.10 → 0.0.11
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/.github/copilot-instructions.md +7 -1
- package/dist/docs/backend-only.md +204 -0
- package/dist/docs/commands.md +453 -0
- package/dist/docs/email.md +6 -0
- package/dist/docs/env.md +224 -0
- package/dist/docs/error-handling.md +35 -23
- package/dist/docs/fetching-data.md +3 -1
- package/dist/docs/get-started-ia.md +480 -0
- package/dist/docs/index.md +46 -2
- package/dist/docs/installation.md +21 -2
- package/dist/docs/layouts-and-pages.md +13 -1
- package/dist/docs/mcp.md +4 -1
- package/dist/docs/metadata-and-og-images.md +34 -22
- package/dist/docs/prisma-php-orm.md +1 -1
- package/dist/docs/project-structure.md +16 -2
- package/dist/docs/pulsepoint.md +5 -0
- package/dist/docs/route-handlers.md +18 -2
- package/dist/docs/swagger-docs.md +189 -0
- package/dist/docs/upgrading.md +13 -9
- package/dist/docs/websocket.md +4 -0
- package/package.json +1 -1
package/dist/docs/email.md
CHANGED
|
@@ -5,6 +5,7 @@ related:
|
|
|
5
5
|
title: Related docs
|
|
6
6
|
description: Read the official Prisma PHP email docs before generating or editing mail flows.
|
|
7
7
|
links:
|
|
8
|
+
- /docs/env
|
|
8
9
|
- /docs/email-get-started
|
|
9
10
|
- /docs/env-file
|
|
10
11
|
- /docs/php-validator
|
|
@@ -33,6 +34,7 @@ Do not assume another framework's mailer abstraction applies directly.
|
|
|
33
34
|
## Read this doc when you need
|
|
34
35
|
|
|
35
36
|
- **SMTP setup, `.env` mail variables, `PP\PHPMailer\Mailer`, `sendEmail`, HTML email, text email, `from`, `to`, `cc`, `bcc`, `replyTo`, or attachments** → official `email-get-started`
|
|
37
|
+
- **custom runtime reads of SMTP values, mail feature flags, or `.env` loading boundaries** → `env.md` plus `email.md`
|
|
36
38
|
- **contact forms or page-local email sends via PulsePoint** → `fetching-data.md` plus `email.md`
|
|
37
39
|
- **direct POST handlers or handler-only email routes** → `route-handlers.md` plus `email.md`
|
|
38
40
|
- **validation of recipient, sender, or contact-form input** → `validator.md` plus `email.md`
|
|
@@ -44,6 +46,8 @@ The Prisma PHP mailer is a PHPMailer wrapper with a fluent API.
|
|
|
44
46
|
|
|
45
47
|
The constructor initializes a `PHPMailer` instance, forces `UTF-8`, configures SMTP transport from `.env`, and applies a default sender when `MAIL_FROM` is present and valid.
|
|
46
48
|
|
|
49
|
+
When a task goes beyond the built-in mailer workflow and needs direct runtime config access, AI should route that part through `PP\Env` and `env.md` instead of adding ad hoc `getenv()` parsing.
|
|
50
|
+
|
|
47
51
|
AI should preserve that model instead of replacing it with undocumented helpers or raw `mail()` calls.
|
|
48
52
|
|
|
49
53
|
## Exact core file location
|
|
@@ -82,6 +86,8 @@ Behavior notes:
|
|
|
82
86
|
|
|
83
87
|
AI should update `.env` whenever email support is introduced and should not hardcode SMTP credentials in route files or components.
|
|
84
88
|
|
|
89
|
+
If application code needs to read related mail settings directly, prefer `PP\Env` typed helpers so defaults and empty-value handling stay consistent with the Prisma PHP env implementation.
|
|
90
|
+
|
|
85
91
|
## Public fluent methods AI should know
|
|
86
92
|
|
|
87
93
|
The current `Mailer` class exposes:
|
package/dist/docs/env.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Env
|
|
3
|
+
description: Learn how Prisma PHP reads environment values with PP\Env so AI agents can use typed env helpers, understand the .env loading boundary, and avoid ad hoc getenv parsing.
|
|
4
|
+
related:
|
|
5
|
+
title: Related docs
|
|
6
|
+
description: Read the official Prisma PHP env docs before generating or editing configuration access code.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/env
|
|
9
|
+
- /docs/env-file
|
|
10
|
+
- /docs/project-structure
|
|
11
|
+
- /docs/prisma-php-ai-mcp
|
|
12
|
+
- /docs/websocket-get-started
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Prisma PHP environment access should follow the documented `PP\Env` model, not ad hoc parsing copied from Laravel config helpers, Symfony parameter bags, or repeated raw `getenv()` checks scattered across the codebase.
|
|
16
|
+
|
|
17
|
+
If a task involves `.env`, environment variables, feature flags, host and port values, timezones, API keys, numeric limits, or typed runtime configuration reads, AI agents should read the relevant Prisma PHP env docs first and keep the implementation aligned with the installed Prisma PHP version.
|
|
18
|
+
|
|
19
|
+
## AI rule: read the Env docs first
|
|
20
|
+
|
|
21
|
+
Before generating, editing, or reviewing environment-related code, use this order:
|
|
22
|
+
|
|
23
|
+
1. Read `./prisma-php.json` when the task is in a generated Prisma PHP app.
|
|
24
|
+
2. Read the installed local docs in `node_modules/prisma-php/dist/docs`.
|
|
25
|
+
3. Read this `env.md` file.
|
|
26
|
+
4. Inspect the current `.env` file or deployment environment when the task depends on real values.
|
|
27
|
+
5. Inspect the bootstrap or server entry file that loads or consumes environment variables.
|
|
28
|
+
6. Inspect Prisma PHP core internals only when the docs do not answer the task.
|
|
29
|
+
|
|
30
|
+
Do not assume another framework's env loader or configuration container applies directly.
|
|
31
|
+
|
|
32
|
+
## Read this doc when you need
|
|
33
|
+
|
|
34
|
+
- **`.env`, environment variables, `PP\Env`, `Env::get(...)`, `Env::string(...)`, `Env::bool(...)`, or `Env::int(...)`** -> official `env`
|
|
35
|
+
- **`.env` file placement, runtime loading, or dotenv bootstrapping** -> official `env-file` plus `env.md`
|
|
36
|
+
- **runtime settings for websocket or MCP servers** -> `websocket.md` or `mcp.md` plus `env.md`
|
|
37
|
+
- **SMTP credentials, sender defaults, or provider secrets** -> `email.md` or `get-started-ia.md` plus `env.md`
|
|
38
|
+
- **database connection strings and Prisma datasource config** -> `prisma-php-orm.md` plus `env.md`
|
|
39
|
+
|
|
40
|
+
## Core Env model AI should follow
|
|
41
|
+
|
|
42
|
+
Prisma PHP documents environment access around a lightweight helper class:
|
|
43
|
+
|
|
44
|
+
- `PP\Env` reads values that already exist in the runtime
|
|
45
|
+
- it provides raw access through `get()`
|
|
46
|
+
- it provides typed helpers through `string()`, `bool()`, and `int()`
|
|
47
|
+
- it centralizes default handling instead of repeating parsing logic in multiple files
|
|
48
|
+
|
|
49
|
+
AI should preserve that model instead of re-implementing manual conversion everywhere.
|
|
50
|
+
|
|
51
|
+
## Exact core file location
|
|
52
|
+
|
|
53
|
+
The Prisma PHP core `Env` class lives here:
|
|
54
|
+
|
|
55
|
+
```txt
|
|
56
|
+
vendor/tsnc/prisma-php/src/Env.php
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When AI needs to inspect framework internals because the docs do not fully answer an env task, this is the exact core file to review.
|
|
60
|
+
|
|
61
|
+
## Resolution order and normalization
|
|
62
|
+
|
|
63
|
+
The current `Env` implementation resolves values in this order:
|
|
64
|
+
|
|
65
|
+
1. `getenv()`
|
|
66
|
+
2. `$_ENV`
|
|
67
|
+
3. `$_SERVER`
|
|
68
|
+
|
|
69
|
+
Normalization behavior:
|
|
70
|
+
|
|
71
|
+
- booleans become `'true'` or `'false'`
|
|
72
|
+
- scalar values are cast to strings
|
|
73
|
+
- unsupported types such as arrays or objects return `null`
|
|
74
|
+
|
|
75
|
+
That means `Env` is safe for central configuration reads, but it is not a substitute for validating arbitrary request payloads.
|
|
76
|
+
|
|
77
|
+
## Public methods AI should know
|
|
78
|
+
|
|
79
|
+
The current `Env` class exposes:
|
|
80
|
+
|
|
81
|
+
- `static get(string $key): ?string`
|
|
82
|
+
- `static string(string $key, string $default = ''): string`
|
|
83
|
+
- `static bool(string $key, bool $default = false): bool`
|
|
84
|
+
- `static int(string $key, int $default = 0): int`
|
|
85
|
+
|
|
86
|
+
Do not invent undocumented helper methods when this public surface already covers the common Prisma PHP configuration workflow.
|
|
87
|
+
|
|
88
|
+
## Method behavior summary
|
|
89
|
+
|
|
90
|
+
Use `get()` when you want the raw nullable string value and plan to handle parsing yourself.
|
|
91
|
+
|
|
92
|
+
Use `string()` for values such as:
|
|
93
|
+
|
|
94
|
+
- app names
|
|
95
|
+
- timezones
|
|
96
|
+
- URLs
|
|
97
|
+
- API keys
|
|
98
|
+
- driver names
|
|
99
|
+
|
|
100
|
+
Behavior note:
|
|
101
|
+
|
|
102
|
+
- `string()` returns the default when the value is missing or when it is an empty string
|
|
103
|
+
|
|
104
|
+
Use `bool()` for values such as:
|
|
105
|
+
|
|
106
|
+
- feature flags
|
|
107
|
+
- verbose logging toggles
|
|
108
|
+
- JSON response toggles
|
|
109
|
+
- debug mode switches
|
|
110
|
+
|
|
111
|
+
Accepted boolean-like values are case-insensitive:
|
|
112
|
+
|
|
113
|
+
- `true` and `false`
|
|
114
|
+
- `1` and `0`
|
|
115
|
+
- `yes` and `no`
|
|
116
|
+
- `on` and `off`
|
|
117
|
+
|
|
118
|
+
Behavior note:
|
|
119
|
+
|
|
120
|
+
- invalid boolean strings fall back to the provided default
|
|
121
|
+
|
|
122
|
+
Use `int()` for values such as:
|
|
123
|
+
|
|
124
|
+
- port numbers
|
|
125
|
+
- timeouts
|
|
126
|
+
- retry limits
|
|
127
|
+
- upload limits
|
|
128
|
+
- cache durations
|
|
129
|
+
|
|
130
|
+
Behavior note:
|
|
131
|
+
|
|
132
|
+
- `int()` only converts numeric values; otherwise it returns the default
|
|
133
|
+
|
|
134
|
+
## Important `.env` boundary
|
|
135
|
+
|
|
136
|
+
`PP\Env` does not parse a `.env` file by itself.
|
|
137
|
+
|
|
138
|
+
It only reads values that are already present in the PHP runtime. When Prisma PHP needs to load `.env` values from disk first, the bootstrap or server entry typically does that explicitly, for example with `Dotenv::createImmutable(...)->safeLoad()`.
|
|
139
|
+
|
|
140
|
+
AI should keep that boundary clear:
|
|
141
|
+
|
|
142
|
+
- use dotenv loading when the runtime has not loaded `.env` yet
|
|
143
|
+
- use `PP\Env` when reading values after the environment is available
|
|
144
|
+
- do not describe `PP\Env` as a standalone dotenv parser
|
|
145
|
+
|
|
146
|
+
## Recommended example patterns
|
|
147
|
+
|
|
148
|
+
### Bootstrap runtime settings
|
|
149
|
+
|
|
150
|
+
```php
|
|
151
|
+
<?php
|
|
152
|
+
|
|
153
|
+
declare(strict_types=1);
|
|
154
|
+
|
|
155
|
+
use Dotenv\Dotenv;
|
|
156
|
+
use PP\Env;
|
|
157
|
+
|
|
158
|
+
if (file_exists(DOCUMENT_PATH . '/.env')) {
|
|
159
|
+
Dotenv::createImmutable(DOCUMENT_PATH)->safeLoad();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
date_default_timezone_set(Env::string('APP_TIMEZONE', 'UTC'));
|
|
163
|
+
|
|
164
|
+
$showErrors = Env::bool('SHOW_ERRORS', false);
|
|
165
|
+
$appName = Env::string('APP_NAME', 'Prisma PHP App');
|
|
166
|
+
$appPort = Env::int('APP_PORT', 3000);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Fail early for required secrets
|
|
170
|
+
|
|
171
|
+
```php
|
|
172
|
+
<?php
|
|
173
|
+
|
|
174
|
+
use PP\Env;
|
|
175
|
+
|
|
176
|
+
$openAiKey = Env::string('OPENAI_API_KEY', '');
|
|
177
|
+
|
|
178
|
+
if ($openAiKey === '') {
|
|
179
|
+
throw new Exception('OPENAI_API_KEY is missing.');
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Inspect a raw value directly
|
|
184
|
+
|
|
185
|
+
```php
|
|
186
|
+
<?php
|
|
187
|
+
|
|
188
|
+
use PP\Env;
|
|
189
|
+
|
|
190
|
+
$driver = Env::get('DB_DRIVER');
|
|
191
|
+
|
|
192
|
+
if ($driver === null) {
|
|
193
|
+
$driver = 'mysql';
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Example environment values
|
|
198
|
+
|
|
199
|
+
```dotenv
|
|
200
|
+
APP_NAME="Prisma PHP"
|
|
201
|
+
APP_TIMEZONE="UTC"
|
|
202
|
+
APP_PORT=3000
|
|
203
|
+
SHOW_ERRORS=true
|
|
204
|
+
OPENAI_API_KEY="sk-..."
|
|
205
|
+
DB_DRIVER="mysql"
|
|
206
|
+
MAX_UPLOAD_MB=20
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Common patterns AI should preserve
|
|
210
|
+
|
|
211
|
+
- prefer `string()`, `bool()`, and `int()` over repeated manual parsing
|
|
212
|
+
- always provide a sensible default for optional settings
|
|
213
|
+
- validate critical secrets explicitly and fail early when they are missing
|
|
214
|
+
- keep configuration reads near bootstrap or server setup when possible
|
|
215
|
+
- pass resolved configuration into the parts of the system that need it instead of re-reading the same keys everywhere
|
|
216
|
+
|
|
217
|
+
## AI rules for env tasks
|
|
218
|
+
|
|
219
|
+
- read `env.md` before generating environment-related Prisma PHP code
|
|
220
|
+
- prefer `PP\Env` over ad hoc `getenv()` parsing when working inside documented Prisma PHP code paths
|
|
221
|
+
- keep secrets and deployment values in `.env` or the runtime environment, not hardcoded in route files or components
|
|
222
|
+
- remember that `PP\Env` reads already-loaded values and does not load `.env` on its own
|
|
223
|
+
- use defaults for optional settings and explicit checks for required secrets
|
|
224
|
+
- inspect `vendor/tsnc/prisma-php/src/Env.php` only when the docs and current app code do not answer the task
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Error Handling
|
|
3
|
-
description: Learn how
|
|
3
|
+
description: Learn how Prisma PHP handles expected errors and uncaught exceptions so AI agents can keep validation failures separate from crashes.
|
|
4
4
|
related:
|
|
5
5
|
title: API Reference
|
|
6
6
|
description: Learn more about the features mentioned on this page by reading the Prisma PHP docs.
|
|
@@ -17,7 +17,19 @@ Errors in Prisma PHP can be thought of in two broad categories:
|
|
|
17
17
|
1. **Expected errors** — validation failures, missing records, failed form submissions, or known request problems
|
|
18
18
|
2. **Unexpected errors** — uncaught exceptions, fatal errors, parse errors, or framework-level failures
|
|
19
19
|
|
|
20
|
-
Prisma PHP’s documented error model is centered around the `ErrorHandler` class, which acts as the application safety net. It captures exceptions, fatal errors, and parse errors, then converts them into structured responses depending on the request context. For AJAX-style requests it can return JSON; for browser rendering it can show a richer diagnostic UI.
|
|
20
|
+
Prisma PHP’s documented error model is centered around the `ErrorHandler` class, which acts as the application safety net. It captures exceptions, fatal errors, and parse errors, then converts them into structured responses depending on the request context. For AJAX-style requests it can return JSON; for browser rendering it can show a richer diagnostic UI.
|
|
21
|
+
|
|
22
|
+
If a task involves expected validation failures, missing records, `Boom` responses, `error.php`, `not-found.php`, or uncaught exceptions, AI agents should read this page first and keep routine failures separate from true crashes.
|
|
23
|
+
|
|
24
|
+
## AI rule: read the error-handling docs first
|
|
25
|
+
|
|
26
|
+
Before generating Prisma PHP error flows, use this order:
|
|
27
|
+
|
|
28
|
+
1. Decide whether the failure is expected or unexpected.
|
|
29
|
+
2. Use `PP\Validator` and structured return values for expected input problems.
|
|
30
|
+
3. Use `Boom`, `error.php`, `not-found.php`, or `ErrorHandler` for request and app-level error behavior.
|
|
31
|
+
4. Keep `route.php`, `pp.fetchFunction(...)`, and form responses explicit instead of turning routine validation into exceptions.
|
|
32
|
+
5. Read `validator.md` and `route-handlers.md` when the error starts from request validation.
|
|
21
33
|
|
|
22
34
|
## Handling expected errors
|
|
23
35
|
|
|
@@ -197,7 +209,7 @@ The docs describe `ErrorHandler` as the safety net for the application. It captu
|
|
|
197
209
|
|
|
198
210
|
- exceptions
|
|
199
211
|
- fatal errors
|
|
200
|
-
- parse errors
|
|
212
|
+
- parse errors
|
|
201
213
|
|
|
202
214
|
This makes it the Prisma PHP equivalent of a central application error boundary, but implemented at the PHP framework level rather than with React client components.
|
|
203
215
|
|
|
@@ -206,13 +218,13 @@ This makes it the Prisma PHP equivalent of a central application error boundary,
|
|
|
206
218
|
Prisma PHP’s `ErrorHandler` automatically detects the request context and chooses the appropriate output format. The docs explicitly say it can return:
|
|
207
219
|
|
|
208
220
|
- a JSON payload for AJAX requests
|
|
209
|
-
- a rich diagnostic UI for browser requests
|
|
221
|
+
- a rich diagnostic UI for browser requests
|
|
210
222
|
|
|
211
223
|
This is one of the biggest differences from Next.js. Instead of defining client-side error boundaries with `error.js`, Prisma PHP handles failures centrally on the server and formats the response according to the request type.
|
|
212
224
|
|
|
213
225
|
## Rich diagnostics
|
|
214
226
|
|
|
215
|
-
The Prisma PHP docs emphasize that `ErrorHandler` does more than show a generic PHP crash page. It can generate context-aware diagnostics for framework-specific failures.
|
|
227
|
+
The Prisma PHP docs emphasize that `ErrorHandler` does more than show a generic PHP crash page. It can generate context-aware diagnostics for framework-specific failures.
|
|
216
228
|
|
|
217
229
|
### Component validation diagnostics
|
|
218
230
|
|
|
@@ -221,7 +233,7 @@ When a component receives invalid props, the docs say the error UI can show:
|
|
|
221
233
|
- the specific component name
|
|
222
234
|
- the invalid property
|
|
223
235
|
- quick fixes such as adding a missing public property
|
|
224
|
-
- a list of currently available props
|
|
236
|
+
- a list of currently available props
|
|
225
237
|
|
|
226
238
|
### Template compilation diagnostics
|
|
227
239
|
|
|
@@ -229,7 +241,7 @@ When the template engine fails to parse a file, the docs say the error UI can:
|
|
|
229
241
|
|
|
230
242
|
- identify syntax errors in PulsePoint-specific tags
|
|
231
243
|
- highlight the specific line in the view file
|
|
232
|
-
- provide suggestions on how to correct the syntax
|
|
244
|
+
- provide suggestions on how to correct the syntax
|
|
233
245
|
|
|
234
246
|
This means Prisma PHP’s error page is intended to be an actionable developer tool, not only a fallback screen.
|
|
235
247
|
|
|
@@ -241,7 +253,7 @@ Prisma PHP allows you to override the default error output by creating:
|
|
|
241
253
|
APP_PATH . '/error.php'
|
|
242
254
|
```
|
|
243
255
|
|
|
244
|
-
The docs state that if this file exists, `ErrorHandler` will render it inside your main layout wrapper instead of using the default output.
|
|
256
|
+
The docs state that if this file exists, `ErrorHandler` will render it inside your main layout wrapper instead of using the default output.
|
|
245
257
|
|
|
246
258
|
That makes `error.php` the main file convention for customizing browser-visible application errors.
|
|
247
259
|
|
|
@@ -256,9 +268,9 @@ Example:
|
|
|
256
268
|
|
|
257
269
|
## Output buffering behavior
|
|
258
270
|
|
|
259
|
-
The docs note an important implementation detail: when a fatal error occurs, the handler calls `ob_end_clean()` to remove any partial HTML that was generated before the crash. This prevents broken layouts or incomplete output from being rendered.
|
|
271
|
+
The docs note an important implementation detail: when a fatal error occurs, the handler calls `ob_end_clean()` to remove any partial HTML that was generated before the crash. This prevents broken layouts or incomplete output from being rendered.
|
|
260
272
|
|
|
261
|
-
The docs also mention that if you are debugging with `echo` or `var_dump` immediately before a crash, you may need to temporarily disable this buffer cleaning in `modifyOutputLayoutForError` in order to see that debug output.
|
|
273
|
+
The docs also mention that if you are debugging with `echo` or `var_dump` immediately before a crash, you may need to temporarily disable this buffer cleaning in `modifyOutputLayoutForError` in order to see that debug output.
|
|
262
274
|
|
|
263
275
|
## Key methods
|
|
264
276
|
|
|
@@ -272,15 +284,15 @@ Registers:
|
|
|
272
284
|
- `register_shutdown_function`
|
|
273
285
|
- `set_error_handler`
|
|
274
286
|
|
|
275
|
-
The docs say this is usually called in `bootstrap.php`.
|
|
287
|
+
The docs say this is usually called in `bootstrap.php`.
|
|
276
288
|
|
|
277
289
|
### `checkFatalError(): void`
|
|
278
290
|
|
|
279
|
-
Manually checks `error_get_last()`. The docs describe this as useful for catching shutdown-time errors that are not regular exceptions.
|
|
291
|
+
Manually checks `error_get_last()`. The docs describe this as useful for catching shutdown-time errors that are not regular exceptions.
|
|
280
292
|
|
|
281
293
|
### `formatExceptionForDisplay(Throwable $e): string`
|
|
282
294
|
|
|
283
|
-
Formats an exception into the rich HTML diagnostic output. The docs say it determines whether the error is a standard PHP exception or a specific PulsePoint framework error.
|
|
295
|
+
Formats an exception into the rich HTML diagnostic output. The docs say it determines whether the error is a standard PHP exception or a specific PulsePoint framework error.
|
|
284
296
|
|
|
285
297
|
## Bootstrap registration
|
|
286
298
|
|
|
@@ -315,7 +327,7 @@ try {
|
|
|
315
327
|
}
|
|
316
328
|
```
|
|
317
329
|
|
|
318
|
-
This is useful when you want to catch an exception yourself but still use the framework’s standard rich diagnostic output.
|
|
330
|
+
This is useful when you want to catch an exception yourself but still use the framework’s standard rich diagnostic output.
|
|
319
331
|
|
|
320
332
|
## `index.php` vs `route.php` error handling
|
|
321
333
|
|
|
@@ -323,7 +335,7 @@ Error handling in Prisma PHP still follows the route model:
|
|
|
323
335
|
|
|
324
336
|
- in `index.php`, errors usually affect rendered page output
|
|
325
337
|
- in `route.php`, errors usually affect JSON or direct handler responses
|
|
326
|
-
- the `ErrorHandler` adapts the response format based on request context
|
|
338
|
+
- the `ErrorHandler` adapts the response format based on request context
|
|
327
339
|
|
|
328
340
|
For full-stack projects, expected user-facing problems should usually be handled gracefully in `index.php` or in direct function responses. For API-style routes, structured JSON error responses are usually the right choice for expected failures. Uncaught exceptions should be left to the framework-level `ErrorHandler`.
|
|
329
341
|
|
|
@@ -343,14 +355,14 @@ The main difference is that Prisma PHP’s documented error handling is server-d
|
|
|
343
355
|
|
|
344
356
|
## Good to know
|
|
345
357
|
|
|
346
|
-
- Prisma PHP’s documented error system is `ErrorHandler`.
|
|
347
|
-
- It captures exceptions, fatal errors, and parse errors.
|
|
348
|
-
- It automatically switches output based on request context.
|
|
349
|
-
- AJAX-style requests can receive JSON errors.
|
|
350
|
-
- Browser requests can receive a rich diagnostic UI.
|
|
351
|
-
- You can override the default error view with `APP_PATH . '/error.php'`.
|
|
352
|
-
- Fatal-error handling clears partial output with `ob_end_clean()`.
|
|
353
|
-
- `registerHandlers()` is usually called in `bootstrap.php`.
|
|
358
|
+
- Prisma PHP’s documented error system is `ErrorHandler`.
|
|
359
|
+
- It captures exceptions, fatal errors, and parse errors.
|
|
360
|
+
- It automatically switches output based on request context.
|
|
361
|
+
- AJAX-style requests can receive JSON errors.
|
|
362
|
+
- Browser requests can receive a rich diagnostic UI.
|
|
363
|
+
- You can override the default error view with `APP_PATH . '/error.php'`.
|
|
364
|
+
- Fatal-error handling clears partial output with `ob_end_clean()`.
|
|
365
|
+
- `registerHandlers()` is usually called in `bootstrap.php`.
|
|
354
366
|
|
|
355
367
|
## Validation vs unexpected failures
|
|
356
368
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Fetching Data
|
|
3
|
-
description: Learn how
|
|
3
|
+
description: Learn how AI agents should fetch and stream data in Prisma PHP using `pp.fetchFunction`, `#[Exposed]`, page handlers, SSE responses, and route handlers.
|
|
4
4
|
related:
|
|
5
5
|
title: API Reference
|
|
6
6
|
description: Learn more about the features mentioned in this page by reading the Prisma PHP docs.
|
|
@@ -14,6 +14,8 @@ related:
|
|
|
14
14
|
|
|
15
15
|
This page will walk you through how you can fetch and stream data in Prisma PHP, when to use `pp.fetchFunction(...)`, when to use `index.php`, when to use `route.php`, and how to validate incoming data correctly on the PHP side.
|
|
16
16
|
|
|
17
|
+
If a task involves page-local interactivity, exposed PHP functions, streamed responses, or deciding between `index.php` and `route.php`, AI agents should read this page first and keep the interaction model aligned with Prisma PHP.
|
|
18
|
+
|
|
17
19
|
Prisma PHP has a different mental model from Next.js. Instead of focusing on React Server Components, Suspense-driven HTML streaming, and client data libraries, Prisma PHP gives you direct function invocation from the frontend to PHP, plus file-based routing for page UI and direct route handlers.
|
|
18
20
|
|
|
19
21
|
When using `pp.fetchFunction(...)`, the PHP function must be explicitly exposed with `#[Exposed]`. Functions are private by default, so a non-exposed function cannot be called from the client.
|