create-prisma-php-app 5.0.0-alpha.2 → 5.0.0-alpha.20
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/AGENTS.md +423 -123
- package/dist/bootstrap.php +32 -4
- package/dist/index.js +2 -2
- package/dist/prisma-php.js +1 -1
- package/dist/public/js/pp-reactive-v2.js +1 -1
- package/dist/src/Lib/Auth/Auth.php +53 -12
- package/dist/src/Lib/Middleware/AuthMiddleware.php +2 -2
- package/dist/src/Lib/Middleware/CorsMiddleware.php +4 -0
- package/package.json +1 -1
- package/dist/README.md +0 -196
package/dist/AGENTS.md
CHANGED
|
@@ -2,104 +2,110 @@
|
|
|
2
2
|
|
|
3
3
|
# Prisma PHP AI Agent Rules
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This AGENTS.md belongs in the root of a Prisma PHP application.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Treat `./node_modules/prisma-php/dist/docs/index.md` as the entry point for Prisma PHP guidance, then read the matching document in `./node_modules/prisma-php/dist/docs` before generating, editing, reviewing, or documenting framework-specific behavior.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Do not guess framework behavior from Laravel, Next.js, React, Vue, Livewire, Alpine, Symfony, Socket.IO, or generic PHP habits. Prisma PHP's installed docs in `./node_modules/prisma-php/dist/docs` and the current project files are the source of truth.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Documentation source of truth
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
For Prisma PHP projects, use this order first:
|
|
14
|
+
|
|
15
|
+
1. the user's explicit request
|
|
14
16
|
2. `./prisma-php.json`
|
|
15
|
-
3.
|
|
16
|
-
4.
|
|
17
|
-
5.
|
|
18
|
-
6.
|
|
17
|
+
3. the relevant installed document in `./node_modules/prisma-php/dist/docs`
|
|
18
|
+
4. `./AGENTS.md`
|
|
19
|
+
5. project-local conventions and existing app files
|
|
20
|
+
6. Prisma PHP core internals in `vendor/tsnc/prisma-php/src` only when the docs still leave a gap
|
|
21
|
+
7. general framework knowledge as the last fallback
|
|
22
|
+
|
|
23
|
+
Important rules:
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
- treat `./node_modules/prisma-php/dist/docs` as the single documentation source of truth for the installed Prisma PHP version
|
|
26
|
+
- expect `./AGENTS.md` at the project root
|
|
27
|
+
- when the installed docs and a habit from another framework conflict, follow Prisma PHP
|
|
28
|
+
- when updating Prisma PHP package/docs sources, keep `AGENTS.md` and `dist/docs` aligned for consumer apps; if the Prisma PHP package source repo also maintains `.github/copilot-instructions.md`, keep that source-repo file aligned there too
|
|
21
29
|
|
|
22
30
|
## Installed docs location
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
In Prisma PHP applications, the installed docs live in:
|
|
25
33
|
|
|
26
34
|
```txt
|
|
27
35
|
node_modules/prisma-php/dist/docs
|
|
28
36
|
```
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
The current docs entry point for the installed version is:
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
```txt
|
|
41
|
+
node_modules/prisma-php/dist/docs/index.md
|
|
42
|
+
```
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
The project root should also include:
|
|
37
45
|
|
|
38
46
|
```txt
|
|
39
|
-
|
|
47
|
+
AGENTS.md
|
|
40
48
|
```
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
## Required doc-routing map
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
Before generating code, examples, instructions, or reviews, choose the documentation file based on the task.
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
- `backendOnly`
|
|
48
|
-
- `swaggerDocs`
|
|
49
|
-
- `websocket`
|
|
50
|
-
- `mcp`
|
|
51
|
-
- `prisma`
|
|
52
|
-
- `typescript`
|
|
54
|
+
### Read these docs first for these tasks
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
- **Framework orientation, repo-wide guidance, or the high-level AI quick start**
|
|
57
|
+
Read `index.md`
|
|
55
58
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
- BrowserSync target and path rewrite rules
|
|
59
|
-
- component scan directories
|
|
60
|
-
- excluded files
|
|
59
|
+
- **Project setup, folder placement, route file choice, feature placement, or overall file conventions**
|
|
60
|
+
Read `project-structure.md`
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
- **CLI project creation, starter kits, feature flags, or `npx pp update project` usage**
|
|
63
|
+
Read `commands.md`
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
- **Backend-only Prisma PHP usage, API-first projects, `backendOnly`, separate frontend consumers, or CORS setup for API routes**
|
|
66
|
+
Read `backend-only.md`
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
- **Creating a page, layout, nested route, dynamic route, or normal UI route**
|
|
69
|
+
Read `layouts-and-pages.md`
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
- **Creating, editing, composing, or reviewing PHPX components, props, children, fragments, icons, buttons, accordions, or component file placement**
|
|
72
|
+
Read `components.md`
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
- **TypeScript frontend tooling, the `typescript` feature flag, the root `ts/` directory, `ts/main.ts`, npm packages, or registered browser helpers used from template expressions and PulsePoint scripts**
|
|
75
|
+
Read `typescript.md`, then use `pulsepoint.md`, `layouts-and-pages.md`, or `components.md` for the affected component boundary
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
- **Loading data, calling backend logic from the frontend, `pp.fetchFunction(...)`, `#[Exposed]`, route-local mutations, streaming responses, or interactive backend validation**
|
|
78
|
+
Read `fetching-data.md`
|
|
73
79
|
|
|
74
|
-
|
|
80
|
+
- **AI integration, provider SDKs, chat UIs, streamed assistant output, or deciding between page-local assistant UI, websocket, and MCP tools**
|
|
81
|
+
Read `get-started-ia.md`, then use `fetching-data.md`, `validator.md`, `websocket.md`, or `mcp.md` as needed
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
3. let Prisma PHP regenerate framework-managed route metadata
|
|
83
|
+
- **PulsePoint runtime behavior such as `pp.state`, `pp.effect`, `pp-for`, `pp-spread`, or `pp-ref`**
|
|
84
|
+
Read `pulsepoint.md`
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
- **Validation, sanitization, `PP\Validator`, `PP\Rule`, field validation, form validation, live validation, or request validation rules**
|
|
87
|
+
Read `validator.md`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
- **Environment variables, `.env`, `PP\Env`, `Env::get`, `Env::string`, `Env::bool`, `Env::int`, feature flags, host and port config, or runtime bootstrap settings**
|
|
90
|
+
Read `env.md`, then verify the official env docs at `env` and `env-file`
|
|
83
91
|
|
|
84
|
-
|
|
92
|
+
- **Bootstrap flow, request initialization, `FUNCTION_CALL_SECRET`, `prisma_php_csrf`, `pp_local_store_key`, route resolution, or runtime init order**
|
|
93
|
+
Read `bootstrap-runtime.md`, then use `env.md`, `fetching-data.md`, or `error-handling.md` as needed
|
|
85
94
|
|
|
86
|
-
- **
|
|
87
|
-
Read `
|
|
95
|
+
- **File uploads, `multipart/form-data`, `$_FILES`, `PP\FileManager\UploadFile`, rename flows, replace flows, delete flows, allowed file types, upload size rules, or file manager UI behavior**
|
|
96
|
+
Read `file-manager.md`, then verify the official File Manager docs and, when internals matter, the core upload file at `vendor/tsnc/prisma-php/src/FileManager/UploadFile.php`
|
|
88
97
|
|
|
89
|
-
- **
|
|
90
|
-
Read `
|
|
98
|
+
- **SMTP setup, `.env` mail variables, `PP\PHPMailer\Mailer`, HTML bodies, plain-text bodies, recipients, reply-to, CC, BCC, or attachments**
|
|
99
|
+
Read `email.md`, then verify the official email docs at `email-get-started`
|
|
91
100
|
|
|
92
|
-
- **
|
|
93
|
-
Read `
|
|
101
|
+
- **Ratchet websocket setup, `IoServer`, `HttpServer`, `WsServer`, `ConnectionManager`, browser `WebSocket`, or realtime route behavior**
|
|
102
|
+
Read `websocket.md`, then verify the official websocket docs in this order: `websocket-get-started`, `websocket-chat-app`
|
|
94
103
|
|
|
95
|
-
- **
|
|
96
|
-
Read `
|
|
104
|
+
- **MCP support, `#[McpTool]`, `#[Schema]`, `PhpMcp\Server\Server`, `StreamableHttpServerTransport`, AI tool endpoints, or `src/Lib/MCP/mcp-server.php`**
|
|
105
|
+
Read `mcp.md`, then verify the official MCP docs in this order: `prisma-php-ai-mcp`, `ai-tools`
|
|
97
106
|
|
|
98
107
|
- **Authentication strategy, `AuthConfig.php`, route privacy model, sign-in, sign-out, JWT session lifecycle, `refreshUserSession`, RBAC, credentials auth, OAuth, social login, or auth state manager usage**
|
|
99
|
-
Read `authentication.md`, then verify the matching official docs in this order: `auth-get-started`, `credentials`,
|
|
100
|
-
|
|
101
|
-
- **Loading data, calling backend logic from the frontend, `pp.fetchFunction(...)`, `#[Exposed]`, or interactive backend validation**
|
|
102
|
-
Read `fetching-data.md`
|
|
108
|
+
Read `authentication.md`, then verify the matching official docs in this order: `auth-get-started`, `credentials`, `state-manager-auth`
|
|
103
109
|
|
|
104
110
|
- **Cache behavior, route caching, invalidation, or `CacheHandler`**
|
|
105
111
|
Read `caching.md`
|
|
@@ -110,17 +116,14 @@ Before generating code, choose the documentation file based on the task.
|
|
|
110
116
|
- **Expected errors, uncaught exceptions, `error.php`, `not-found.php`, `ErrorHandler`, or validation failures as expected errors**
|
|
111
117
|
Read `error-handling.md`
|
|
112
118
|
|
|
113
|
-
- **Metadata, title, description, head
|
|
119
|
+
- **Metadata, title, description, custom head tags, favicon, icon, apple icon, or `MainLayout` metadata behavior**
|
|
114
120
|
Read `metadata-and-og-images.md`
|
|
115
121
|
|
|
116
|
-
- **API-style routes, JSON responses, handlers, form-processing endpoints, `route.php`, or request validation in handlers**
|
|
122
|
+
- **API-style routes, JSON responses, handlers, webhooks, form-processing endpoints, `route.php`, or request validation in handlers**
|
|
117
123
|
Read `route-handlers.md`
|
|
118
124
|
|
|
119
|
-
- **
|
|
120
|
-
Read `
|
|
121
|
-
|
|
122
|
-
- **Sanitization, `PP\Validator`, `PP\Rule`, field validation, form validation, live validation, or backend validation rules**
|
|
123
|
-
Read the official Validator docs at `https://prismaphp.tsnc.tech/docs/php-validator`, then apply the relevant local guidance from `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
|
|
125
|
+
- **Swagger or OpenAPI generation, `swaggerDocs`, `pphp-swagger.json`, `create-swagger-docs`, or `settings/prisma-schema-config.json`**
|
|
126
|
+
Read `swagger-docs.md`
|
|
124
127
|
|
|
125
128
|
- **Upgrading Prisma PHP, enabling features, syncing framework-managed project files, or running project updates**
|
|
126
129
|
Read `upgrading.md`
|
|
@@ -128,43 +131,252 @@ Before generating code, choose the documentation file based on the task.
|
|
|
128
131
|
- **First-time project installation or app creation flow**
|
|
129
132
|
Read `installation.md`
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
## Docs inventory in this repo
|
|
135
|
+
|
|
136
|
+
The current Prisma PHP docs shipped here include:
|
|
137
|
+
|
|
138
|
+
- `authentication.md`
|
|
139
|
+
- `backend-only.md`
|
|
140
|
+
- `bootstrap-runtime.md`
|
|
141
|
+
- `caching.md`
|
|
142
|
+
- `commands.md`
|
|
143
|
+
- `components.md`
|
|
144
|
+
- `email.md`
|
|
145
|
+
- `env.md`
|
|
146
|
+
- `error-handling.md`
|
|
147
|
+
- `fetching-data.md`
|
|
148
|
+
- `file-manager.md`
|
|
149
|
+
- `get-started-ia.md`
|
|
150
|
+
- `index.md`
|
|
151
|
+
- `installation.md`
|
|
152
|
+
- `layouts-and-pages.md`
|
|
153
|
+
- `mcp.md`
|
|
154
|
+
- `metadata-and-og-images.md`
|
|
155
|
+
- `prisma-php-orm.md`
|
|
156
|
+
- `project-structure.md`
|
|
157
|
+
- `pulsepoint.md`
|
|
158
|
+
- `route-handlers.md`
|
|
159
|
+
- `swagger-docs.md`
|
|
160
|
+
- `typescript.md`
|
|
161
|
+
- `upgrading.md`
|
|
162
|
+
- `validator.md`
|
|
163
|
+
- `websocket.md`
|
|
164
|
+
|
|
165
|
+
When adding or reviewing AI guidance, do not stop at older docs only. Make sure the guidance also covers `backend-only.md`, `email.md`, `env.md`, `get-started-ia.md`, `mcp.md`, `swagger-docs.md`, `typescript.md`, and `websocket.md`, plus newer behavior documented in `fetching-data.md` and `metadata-and-og-images.md`.
|
|
166
|
+
|
|
167
|
+
## Framework-generated files
|
|
168
|
+
|
|
169
|
+
Prisma PHP automatically generates and maintains certain framework files in consumer apps.
|
|
133
170
|
|
|
134
|
-
|
|
171
|
+
### `files-list.json`
|
|
172
|
+
|
|
173
|
+
Do **not** create, edit, reorder, or manually maintain `files-list.json`.
|
|
174
|
+
|
|
175
|
+
Treat `files-list.json` as a framework-generated file for route discovery and internal bookkeeping. When creating, renaming, or removing routes in a Prisma PHP app, make the change in the actual route folders and route files under `src/app` and let Prisma PHP regenerate `files-list.json` automatically.
|
|
135
176
|
|
|
136
|
-
|
|
177
|
+
If a route task appears to require editing `files-list.json`, that is almost certainly the wrong approach.
|
|
137
178
|
|
|
138
|
-
|
|
139
|
-
2. Read the relevant installed doc from `node_modules/prisma-php/dist/docs`
|
|
140
|
-
3. Inspect nearby project files that match the route, feature, or component being changed
|
|
141
|
-
4. If the task is component-related, read `components.md` before generating PHPX component code
|
|
142
|
-
5. If the task is upload- or file-manager-related, read `file-manager.md` before generating upload, rename, delete, or file-listing code
|
|
143
|
-
6. Generate code using Prisma PHP conventions
|
|
144
|
-
7. Inspect `vendor/tsnc/prisma-php/src` only if framework internals are required
|
|
179
|
+
## Framework-managed package scripts
|
|
145
180
|
|
|
146
|
-
|
|
181
|
+
Prisma PHP can generate `package.json` scripts for BrowserSync, Tailwind, TypeScript, WebSocket, MCP, Swagger docs, and related project helpers.
|
|
182
|
+
|
|
183
|
+
AI agents should follow this default rule:
|
|
184
|
+
|
|
185
|
+
- prefer `npm run dev` for ordinary local development
|
|
186
|
+
- prefer `npm run build` for ordinary production-style asset builds
|
|
187
|
+
- do **not** default to telling users to run `npm run tailwind`, `npm run tailwind:build`, `npm run ts:watch`, or `npm run ts:build` after routine file changes, because those are usually framework-managed through the generated top-level scripts
|
|
188
|
+
- use `npm run websocket` or `npm run mcp` only when isolating local runtime startup, debugging, or when the project's scripts show those services are not already covered by the normal development flow
|
|
189
|
+
- use `npm run create-swagger-docs` only when Swagger or OpenAPI output must be intentionally generated or refreshed
|
|
190
|
+
|
|
191
|
+
When a task involves package scripts, read `commands.md` first and inspect the current `package.json` before assuming which feature scripts exist.
|
|
192
|
+
|
|
193
|
+
## Default interactive UI and data-flow rule
|
|
194
|
+
|
|
195
|
+
For normal full-stack Prisma PHP work, assume the user wants the PulsePoint-first approach unless they explicitly ask otherwise.
|
|
196
|
+
|
|
197
|
+
Default interaction stack:
|
|
198
|
+
|
|
199
|
+
1. render route UI with `index.php`
|
|
200
|
+
2. keep browser-side interactivity in PulsePoint
|
|
201
|
+
3. call backend PHP from the frontend with `pp.fetchFunction(...)`
|
|
202
|
+
4. mark callable PHP functions or methods with `#[Exposed]`
|
|
203
|
+
5. validate and normalize input on the PHP side with `PP\Validator`
|
|
204
|
+
|
|
205
|
+
Treat this as the default for:
|
|
206
|
+
|
|
207
|
+
- search
|
|
208
|
+
- filters
|
|
209
|
+
- pagination
|
|
210
|
+
- quick edit flows
|
|
211
|
+
- toggles
|
|
212
|
+
- dialogs and drawers
|
|
213
|
+
- inline validation
|
|
214
|
+
- route-local CRUD actions
|
|
215
|
+
- dashboard interactions
|
|
216
|
+
- streaming assistants
|
|
217
|
+
- progress logs
|
|
218
|
+
- similar reactive page behavior
|
|
219
|
+
|
|
220
|
+
Do **not** default to:
|
|
221
|
+
|
|
222
|
+
- a PHP-only interaction style
|
|
223
|
+
- ad hoc `fetch('/api/...')` patterns
|
|
224
|
+
- extra `route.php` files for page-local interactions that already fit `pp.fetchFunction(...)`
|
|
225
|
+
- a separate Node realtime or tool server when the documented Prisma PHP runtime already fits the task
|
|
226
|
+
|
|
227
|
+
Choose a more PHP-only or handler-only pattern only when:
|
|
228
|
+
|
|
229
|
+
- the user explicitly asks for it
|
|
230
|
+
- the task is clearly non-reactive
|
|
231
|
+
- the task is a standalone API, webhook, integration endpoint, or public JSON handler
|
|
232
|
+
|
|
233
|
+
## Route structure rule AI must not get wrong
|
|
234
|
+
|
|
235
|
+
There are two related structure rules, and AI must not mix their responsibilities.
|
|
236
|
+
|
|
237
|
+
### Normal route files such as `index.php` and nested `layout.php`
|
|
238
|
+
|
|
239
|
+
Use this pattern:
|
|
240
|
+
|
|
241
|
+
1. PHP first
|
|
242
|
+
2. one parent HTML element for the route content
|
|
243
|
+
3. when PulsePoint is present, put `pp-component` on that route root
|
|
244
|
+
4. keep one `<script>` block as the last child inside that same root element
|
|
245
|
+
|
|
246
|
+
Also follow these route-file rules:
|
|
247
|
+
|
|
248
|
+
- `index.php` and nested `layout.php` must render a single parent HTML element
|
|
249
|
+
- only the root `layout.php` should define `<html>`, `<head>`, and `<body>`
|
|
250
|
+
- when PulsePoint is present in a root `layout.php`, keep `MainLayout::$children` and any `<script>` inside one clear wrapper
|
|
251
|
+
|
|
252
|
+
Example:
|
|
253
|
+
|
|
254
|
+
```php
|
|
255
|
+
<?php
|
|
256
|
+
|
|
257
|
+
use PP\MainLayout;
|
|
258
|
+
|
|
259
|
+
MainLayout::$title = 'Todos';
|
|
260
|
+
MainLayout::$description = 'Track tasks and view the current item count.';
|
|
261
|
+
?>
|
|
262
|
+
|
|
263
|
+
<section pp-component="todos-page">
|
|
264
|
+
<h1>Todos</h1>
|
|
265
|
+
<p>Count: {count}</p>
|
|
266
|
+
<script>
|
|
267
|
+
const [count, setCount] = pp.state(0);
|
|
268
|
+
</script>
|
|
269
|
+
</section>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Imported partials rendered with `ImportComponent::render(...)`
|
|
273
|
+
|
|
274
|
+
Use this pattern:
|
|
275
|
+
|
|
276
|
+
1. PHP first
|
|
277
|
+
2. exactly one parent root element
|
|
278
|
+
3. keep any component-local `<script>` inside that root element
|
|
279
|
+
|
|
280
|
+
Example:
|
|
281
|
+
|
|
282
|
+
```php
|
|
283
|
+
<?php
|
|
284
|
+
|
|
285
|
+
// PHP code
|
|
286
|
+
|
|
287
|
+
?>
|
|
288
|
+
|
|
289
|
+
<div pp-component="search-box">
|
|
290
|
+
<h2>Search</h2>
|
|
291
|
+
<input value="{query}" />
|
|
292
|
+
<script>
|
|
293
|
+
console.log('Search component ready');
|
|
294
|
+
</script>
|
|
295
|
+
</div>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Do not:
|
|
299
|
+
|
|
300
|
+
- put a sibling `<script>` next to a route root or imported partial root
|
|
301
|
+
- manually add `pp-component` inside imported partial source
|
|
302
|
+
- assume `ImportComponent` injects `pp-component` for normal route files
|
|
303
|
+
|
|
304
|
+
## Metadata rules
|
|
305
|
+
|
|
306
|
+
For document metadata, prefer `MainLayout::$title` and `MainLayout::$description`.
|
|
307
|
+
|
|
308
|
+
Important metadata rules:
|
|
309
|
+
|
|
310
|
+
- a local `$title` variable only affects rendered page content unless you also assign metadata through `MainLayout`
|
|
311
|
+
- use `MainLayout::addCustomMetadata(...)` for additional `<meta>` values when needed
|
|
312
|
+
- keep visible headings separate from document metadata when the UI text and SEO title must differ
|
|
313
|
+
- read `metadata-and-og-images.md` or `layouts-and-pages.md` before inventing Next.js-style metadata exports or Open Graph image workflows
|
|
314
|
+
|
|
315
|
+
## Streaming and SSE rules
|
|
316
|
+
|
|
317
|
+
Prisma PHP supports streaming through `pp.fetchFunction(...)` when an exposed function yields values.
|
|
318
|
+
|
|
319
|
+
Default streaming rules:
|
|
320
|
+
|
|
321
|
+
- prefer an exposed generator that simply yields strings or arrays
|
|
322
|
+
- let Prisma PHP handle the SSE response automatically for normal `pp.fetchFunction(...)` streaming
|
|
323
|
+
- on the client, put stream UI updates in `onStream`, `onStreamError`, and `onStreamComplete`
|
|
324
|
+
- do not wait for a final JSON payload when the response is streamed
|
|
325
|
+
|
|
326
|
+
Current parsing rules AI should know:
|
|
327
|
+
|
|
328
|
+
- Prisma PHP sends streamed payloads as SSE `data:` lines
|
|
329
|
+
- the built-in `pp.fetchFunction(...)` stream parser currently forwards only `data:` lines to `onStream`
|
|
330
|
+
- `event:`, `id:`, and `retry:` may be emitted by low-level SSE helpers, but the built-in stream callback currently ignores them
|
|
331
|
+
- prefer JSON values or single-line strings for streamed chunks instead of multi-line text blobs
|
|
332
|
+
|
|
333
|
+
Low-level helpers exist when manual SSE control is required:
|
|
334
|
+
|
|
335
|
+
- `PP\Streaming\SSE`
|
|
336
|
+
- `PP\Streaming\ServerSentEvent`
|
|
337
|
+
|
|
338
|
+
Core locations documented for those helpers are:
|
|
339
|
+
|
|
340
|
+
```txt
|
|
341
|
+
vendor/tsnc/prisma-php/src/Streaming/SSE.php
|
|
342
|
+
vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
|
|
343
|
+
```
|
|
147
344
|
|
|
148
345
|
## Route file decision rules
|
|
149
346
|
|
|
150
347
|
When the task is about creating or editing a route, do not guess.
|
|
151
348
|
|
|
152
|
-
Important: creating a route means creating or updating the correct folder and route file under `src/app`. It does **not** mean editing generated route metadata.
|
|
349
|
+
Important: creating a route means creating or updating the correct folder and route file under `src/app`. It does **not** mean editing generated route metadata.
|
|
153
350
|
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
351
|
+
- use `index.php` for rendered UI and normal page routes
|
|
352
|
+
- use `layout.php` for shared UI that wraps route subtrees
|
|
353
|
+
- use `route.php` for direct handlers such as JSON endpoints, API-style routes, AJAX handlers, form-processing endpoints, and webhooks
|
|
354
|
+
- use `not-found.php` for route-specific not-found UI
|
|
355
|
+
- use `error.php` for route or app-level error UI
|
|
356
|
+
- use `loading.php` when the task is specifically about a loading UI state for a route subtree
|
|
159
357
|
|
|
160
|
-
|
|
358
|
+
For normal route-local interactivity, prefer `index.php` plus PulsePoint and `pp.fetchFunction(...)` over inventing extra handlers.
|
|
359
|
+
|
|
360
|
+
In a consumer app, also verify `backendOnly` in `prisma-php.json`:
|
|
161
361
|
|
|
162
362
|
- if `backendOnly` is `false`, normal routes should usually be implemented with `index.php`
|
|
163
363
|
- if `backendOnly` is `true`, route behavior will usually center on `route.php`
|
|
164
364
|
|
|
365
|
+
## Default workflow for AI agents
|
|
366
|
+
|
|
367
|
+
Use this workflow unless the user asks for something narrower.
|
|
368
|
+
|
|
369
|
+
1. read `./prisma-php.json`
|
|
370
|
+
2. read the relevant installed doc from `./node_modules/prisma-php/dist/docs`
|
|
371
|
+
3. inspect `./AGENTS.md` for project-level Prisma PHP guidance
|
|
372
|
+
4. inspect nearby project files that match the route, feature, or component being changed
|
|
373
|
+
5. inspect `vendor/tsnc/prisma-php/src` only if the docs do not answer the task
|
|
374
|
+
|
|
375
|
+
Do not jump directly into framework internals if the current docs already answer the task.
|
|
376
|
+
|
|
165
377
|
## Authentication rules
|
|
166
378
|
|
|
167
|
-
When the task involves auth, do not guess from Laravel,
|
|
379
|
+
When the task involves auth, do not guess from Laravel, generic JWT packages, or ad hoc middleware habits.
|
|
168
380
|
|
|
169
381
|
Use this auth decision flow:
|
|
170
382
|
|
|
@@ -173,15 +385,15 @@ Use this auth decision flow:
|
|
|
173
385
|
3. inspect `src/Lib/Auth/AuthConfig.php` when present
|
|
174
386
|
4. inspect the current auth-related routes under `src/app`
|
|
175
387
|
5. inspect Prisma models that support auth before generating registration, login, or provider code
|
|
176
|
-
6. keep route protection, function protection, and session lifecycle aligned with Prisma PHP
|
|
388
|
+
6. keep route protection, function protection, and session lifecycle aligned with Prisma PHP's documented auth model
|
|
177
389
|
|
|
178
390
|
Important auth rules:
|
|
179
391
|
|
|
180
392
|
- route privacy strategy is configured from `AuthConfig.php`
|
|
181
393
|
- Prisma PHP supports both public-default and private-default route protection strategies
|
|
182
|
-
- sign users in with `Auth::signIn(...)`
|
|
183
|
-
- sign users out with `Auth::signOut(...)`
|
|
184
|
-
- use `refreshUserSession(...)` when current-session auth payloads must be updated after role or profile changes
|
|
394
|
+
- sign users in with `Auth::getInstance()->signIn(...)`
|
|
395
|
+
- sign users out with `Auth::getInstance()->signOut(...)`
|
|
396
|
+
- use `Auth::getInstance()->refreshUserSession(...)` when current-session auth payloads must be updated after role or profile changes
|
|
185
397
|
- use role-based route protection in auth config for page access control
|
|
186
398
|
- use `#[Exposed(allowedRoles: [...])]` for function-level access control when frontend code calls PHP directly
|
|
187
399
|
- for credentials auth, model the schema first, then generate ORM classes before writing auth flows
|
|
@@ -208,7 +420,102 @@ Important file-manager rules:
|
|
|
208
420
|
- do **not** place uploaded files inside `src/app`
|
|
209
421
|
- do **not** assume HTML size hints replace `php.ini` upload limits
|
|
210
422
|
- do **not** invent undocumented storage abstractions when `UploadFile` already fits the task
|
|
211
|
-
|
|
423
|
+
|
|
424
|
+
## Email rules
|
|
425
|
+
|
|
426
|
+
When the task involves email, read `email.md` first.
|
|
427
|
+
|
|
428
|
+
Prisma PHP email follows the documented `PP\PHPMailer\Mailer` model backed by PHPMailer. Do not replace it with raw `mail()`, undocumented wrappers, or habits copied from another mail framework.
|
|
429
|
+
|
|
430
|
+
Use this email workflow:
|
|
431
|
+
|
|
432
|
+
1. read `email.md`
|
|
433
|
+
2. inspect `.env` for SMTP and sender values in the target app
|
|
434
|
+
3. inspect the route, exposed function, or handler that sends the email
|
|
435
|
+
4. inspect the HTML body or attachment source when present
|
|
436
|
+
5. inspect framework internals only when the docs and current app code still leave a gap
|
|
437
|
+
|
|
438
|
+
The documented core mailer file is:
|
|
439
|
+
|
|
440
|
+
```txt
|
|
441
|
+
vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Important email rules:
|
|
445
|
+
|
|
446
|
+
- keep SMTP credentials and sender defaults in `.env`, not in route files
|
|
447
|
+
- the documented env vars are `SMTP_HOST`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_ENCRYPTION`, `SMTP_PORT`, `MAIL_FROM`, and `MAIL_FROM_NAME`
|
|
448
|
+
- validate user-provided email fields before calling the mailer
|
|
449
|
+
- prefer the documented fluent API such as `to(...)`, `subject(...)`, `html(...)`, `text(...)`, `attach(...)`, and `send()`
|
|
450
|
+
- use `raw()` only when low-level PHPMailer access is genuinely needed
|
|
451
|
+
|
|
452
|
+
## Env rules
|
|
453
|
+
|
|
454
|
+
When the task involves `.env`, `PP\Env`, feature flags, ports, host names, timezones, API keys, numeric limits, or other runtime configuration values, read `env.md` first.
|
|
455
|
+
|
|
456
|
+
Use this env workflow:
|
|
457
|
+
|
|
458
|
+
1. read `env.md`
|
|
459
|
+
2. inspect `.env` or the deployment environment when the task depends on actual values
|
|
460
|
+
3. inspect the bootstrap or server entry file that loads or consumes the environment
|
|
461
|
+
4. inspect the feature-specific doc such as `email.md`, `mcp.md`, `websocket.md`, `get-started-ia.md`, or `prisma-php-orm.md` when the env values belong to that feature
|
|
462
|
+
5. inspect `vendor/tsnc/prisma-php/src/Env.php` only if the docs do not answer the task
|
|
463
|
+
|
|
464
|
+
Important env rules:
|
|
465
|
+
|
|
466
|
+
- prefer `PP\Env` over repeated ad hoc `getenv()` parsing in documented Prisma PHP code paths
|
|
467
|
+
- use `Env::string(...)`, `Env::bool(...)`, and `Env::int(...)` for typed access with defaults
|
|
468
|
+
- use `Env::get(...)` when raw nullable string access is actually needed
|
|
469
|
+
- remember that `PP\Env` reads values from `getenv()`, `$_ENV`, and `$_SERVER`; it does not parse `.env` by itself
|
|
470
|
+
- keep secrets and deployment-specific settings in `.env` or the real runtime environment, not hardcoded in route files or components
|
|
471
|
+
|
|
472
|
+
## WebSocket rules
|
|
473
|
+
|
|
474
|
+
When the task involves realtime messaging, presence, live dashboards, `Ratchet`, or browser `WebSocket`, read `websocket.md` first.
|
|
475
|
+
|
|
476
|
+
Prisma PHP websocket support follows a Ratchet-based PHP server plus a `ConnectionManager` under `src/Lib/Websocket`. Do not replace that default with Socket.IO, a separate Node server, or an unrelated hosted realtime service unless the user explicitly asks for a different architecture.
|
|
477
|
+
|
|
478
|
+
Use this websocket workflow:
|
|
479
|
+
|
|
480
|
+
1. read `websocket.md`
|
|
481
|
+
2. inspect whether websocket support is enabled in `prisma-php.json` in the target app
|
|
482
|
+
3. inspect `src/Lib/Websocket`
|
|
483
|
+
4. inspect the route or client script that opens the browser `WebSocket`
|
|
484
|
+
5. inspect `settings/restart-websocket.ts` when local restart behavior matters
|
|
485
|
+
6. inspect framework internals only when the docs do not answer the task
|
|
486
|
+
|
|
487
|
+
Important websocket rules:
|
|
488
|
+
|
|
489
|
+
- use `src/Lib/Websocket/websocket-server.php` as the source of truth for startup behavior
|
|
490
|
+
- use `src/Lib/Websocket/ConnectionManager.php` as the lifecycle boundary for clients and broadcasts
|
|
491
|
+
- preserve documented env vars and defaults: `WS_NAME`, `WS_VERSION`, `WS_HOST`, `WS_PORT`, `WS_VERBOSE`, `APP_TIMEZONE`
|
|
492
|
+
- preserve CLI overrides through `--host=...`, `--port=...`, and `--verbose=...`
|
|
493
|
+
- preserve the documented casing `src/Lib/Websocket`
|
|
494
|
+
- for existing apps, enable `websocket` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
|
|
495
|
+
|
|
496
|
+
## MCP rules
|
|
497
|
+
|
|
498
|
+
When the task involves Model Context Protocol support, read `mcp.md` first.
|
|
499
|
+
|
|
500
|
+
Prisma PHP MCP support follows the documented `PhpMcp\Server` model with attribute-based tool discovery. Do not replace it with custom REST endpoints pretending to be MCP, hand-rolled JSON-RPC parsing, or unrelated agent abstractions when the documented Prisma PHP stack already fits the task.
|
|
501
|
+
|
|
502
|
+
Use this MCP workflow:
|
|
503
|
+
|
|
504
|
+
1. read `mcp.md`
|
|
505
|
+
2. inspect whether MCP support is enabled in `prisma-php.json` in the target app
|
|
506
|
+
3. inspect `src/Lib/MCP`
|
|
507
|
+
4. inspect tool classes and the services they call
|
|
508
|
+
5. inspect auth, ORM, and env configuration when tools read protected or database-backed data
|
|
509
|
+
6. inspect framework internals only when the docs do not answer the task
|
|
510
|
+
|
|
511
|
+
Important MCP rules:
|
|
512
|
+
|
|
513
|
+
- use `src/Lib/MCP/mcp-server.php` as the source of truth for startup behavior
|
|
514
|
+
- preserve attribute-based discovery with `#[McpTool]` and `#[Schema]`
|
|
515
|
+
- preserve the documented discovery model built around scanning the source tree instead of manually wiring every tool class by default
|
|
516
|
+
- preserve the documented casing `src/Lib/MCP`
|
|
517
|
+
- preserve documented env vars and defaults: `MCP_NAME`, `MCP_VERSION`, `MCP_HOST`, `MCP_PORT`, `MCP_PATH_PREFIX`, `MCP_JSON_RESPONSE`, `APP_TIMEZONE`
|
|
518
|
+
- for existing apps, enable `mcp` in `prisma-php.json` and run `npx pp update project -y` before inventing manual scaffolding
|
|
212
519
|
|
|
213
520
|
## Prisma ORM workflow rules
|
|
214
521
|
|
|
@@ -225,29 +532,33 @@ Use this ORM decision flow:
|
|
|
225
532
|
7. after schema synchronization, run `npx ppo generate`
|
|
226
533
|
8. only then write or update PHP code that depends on the generated Prisma classes
|
|
227
534
|
|
|
228
|
-
Important rules:
|
|
535
|
+
Important ORM rules:
|
|
229
536
|
|
|
230
537
|
- do **not** use `npx pp update project -y` as the normal fix for Prisma ORM schema changes
|
|
231
538
|
- use `npx prisma migrate dev` for the normal development migration workflow
|
|
232
539
|
- use `npx prisma migrate deploy` for production or CI/CD migration application
|
|
233
540
|
- use `npx prisma db push` only for explicit prototyping or no-migration database sync
|
|
234
541
|
- do **not** treat `npx ppo generate` as a migration step
|
|
235
|
-
- `npx ppo generate` should run the first time generated PHP ORM classes are needed and whenever `schema.prisma` changes
|
|
236
|
-
- if the task mentions Prisma ORM, `schema.prisma`, migrations, generated classes, SQLite, MySQL, or PostgreSQL, read `prisma-php-orm.md` first
|
|
237
542
|
|
|
238
543
|
## Validation rules
|
|
239
544
|
|
|
240
|
-
When a task involves user input, form handling, search params, JSON payloads, `pp.fetchFunction(...)`,
|
|
545
|
+
When a task involves user input, form handling, search params, JSON payloads, `pp.fetchFunction(...)`, `route.php` bodies, or tool parameters, do not trust raw values.
|
|
241
546
|
|
|
242
547
|
Default Prisma PHP validation rules:
|
|
243
548
|
|
|
244
|
-
- use
|
|
245
|
-
- prefer the
|
|
549
|
+
- use `PP\Validator` as the backend validation and normalization layer
|
|
550
|
+
- prefer the `Rule` builder for rule-based validation
|
|
246
551
|
- validate in PHP even when the frontend already performs local checks
|
|
247
552
|
- return structured validation results for expected failures
|
|
248
553
|
- do not treat routine invalid input as an uncaught exception
|
|
249
554
|
- in reactive flows, use PulsePoint for local state and `Validator` for authoritative server validation
|
|
250
555
|
|
|
556
|
+
When internals matter, the documented Prisma PHP core validator location is:
|
|
557
|
+
|
|
558
|
+
```txt
|
|
559
|
+
vendor/tsnc/prisma-php/src/Validator.php
|
|
560
|
+
```
|
|
561
|
+
|
|
251
562
|
## PulsePoint rules
|
|
252
563
|
|
|
253
564
|
When a task involves reactive frontend behavior, read `pulsepoint.md` first.
|
|
@@ -259,18 +570,6 @@ Also follow these rules:
|
|
|
259
570
|
- keep backend concerns separate from PulsePoint runtime concerns
|
|
260
571
|
- prefer simple documented runtime primitives over abstractions copied from other ecosystems
|
|
261
572
|
|
|
262
|
-
## Reactive frontend + server-call rule
|
|
263
|
-
|
|
264
|
-
For frontend interactivity in Prisma PHP, prefer the documented Prisma PHP pattern:
|
|
265
|
-
|
|
266
|
-
- use **PulsePoint** for reactive browser state and UI behavior
|
|
267
|
-
- use **`pp.fetchFunction(...)`** for page-local or component-local server calls
|
|
268
|
-
- expose callable PHP functions with **`#[Exposed]`**
|
|
269
|
-
|
|
270
|
-
Do not default to handcrafted `fetch('/api/...')` calls, ad hoc AJAX endpoints, or extra `route.php` files when the task is a normal reactive UI interaction that fits `pp.fetchFunction(...)`.
|
|
271
|
-
|
|
272
|
-
Use `route.php` when the user explicitly needs an API-style endpoint, webhook, JSON route, or handler that should exist independently of the current page.
|
|
273
|
-
|
|
274
573
|
## Component rules
|
|
275
574
|
|
|
276
575
|
When the task involves Prisma PHPX components, reusable UI elements, props, children, fragments, icons, buttons, accordions, or component composition, read `components.md` first.
|
|
@@ -281,7 +580,6 @@ Also follow these rules:
|
|
|
281
580
|
- keep component file names and class names aligned
|
|
282
581
|
- preserve documented PHPX patterns for `$props`, `$children`, `$class`, and `getAttributes(...)`
|
|
283
582
|
- follow documented component placement and grouping conventions before inspecting framework internals
|
|
284
|
-
- use `vendor/tsnc/prisma-php/src` only when the installed docs and `components.md` do not answer the task
|
|
285
583
|
|
|
286
584
|
## Prisma PHP XML syntax rules
|
|
287
585
|
|
|
@@ -348,24 +646,30 @@ Do not output permissive HTML shorthand in Prisma PHP UI files.
|
|
|
348
646
|
|
|
349
647
|
## When to inspect framework internals
|
|
350
648
|
|
|
351
|
-
|
|
649
|
+
Inspect framework internals only when the docs and current files do not answer the task.
|
|
650
|
+
|
|
651
|
+
Useful app-mode core locations include:
|
|
352
652
|
|
|
353
653
|
```txt
|
|
354
654
|
vendor/tsnc/prisma-php/src
|
|
655
|
+
vendor/tsnc/prisma-php/src/PHPMailer/Mailer.php
|
|
656
|
+
vendor/tsnc/prisma-php/src/FileManager/UploadFile.php
|
|
657
|
+
vendor/tsnc/prisma-php/src/Validator.php
|
|
658
|
+
vendor/tsnc/prisma-php/src/Streaming/SSE.php
|
|
659
|
+
vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
|
|
355
660
|
```
|
|
356
661
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
Use it when the task involves:
|
|
662
|
+
Use framework internals when the task involves:
|
|
360
663
|
|
|
361
664
|
- confirming namespaces, classes, or helper names
|
|
362
665
|
- understanding how a core class behaves internally
|
|
363
|
-
- verifying available attributes such as `#[Exposed]`
|
|
666
|
+
- verifying available attributes such as `#[Exposed]`, `#[McpTool]`, or `#[Schema]`
|
|
364
667
|
- checking PHPX compiler or template compiler behavior
|
|
365
668
|
- tracing PulsePoint integration points inside Prisma PHP
|
|
366
|
-
-
|
|
669
|
+
- confirming mailer, SSE, websocket, or MCP runtime behavior not already clear from the docs
|
|
670
|
+
- debugging framework-level issues that are not explained by the current docs
|
|
367
671
|
|
|
368
|
-
For ordinary app work, prefer the
|
|
672
|
+
For ordinary app or docs work, prefer the current docs and local project files first.
|
|
369
673
|
|
|
370
674
|
## Upgrade and feature-enable workflow
|
|
371
675
|
|
|
@@ -373,20 +677,16 @@ If the task involves enabling a feature, syncing framework-managed files, or upd
|
|
|
373
677
|
|
|
374
678
|
Important rules:
|
|
375
679
|
|
|
376
|
-
- update `prisma-php.json` before assuming a feature is active
|
|
680
|
+
- update `prisma-php.json` before assuming a feature is active in a consumer app
|
|
377
681
|
- do not assume Tailwind, Prisma, Swagger, WebSocket, MCP, or TypeScript support is enabled unless `prisma-php.json` says so
|
|
378
682
|
- after changing feature flags, follow the documented project update flow
|
|
379
|
-
- for AI-driven or scripted updates, prefer
|
|
380
|
-
|
|
381
|
-
```bash
|
|
382
|
-
npx pp update project -y
|
|
383
|
-
```
|
|
683
|
+
- for AI-driven or scripted updates, prefer `npx pp update project -y`
|
|
384
684
|
|
|
385
|
-
|
|
685
|
+
That command is for project updates and framework-managed file refreshes. It is not the default ORM migration command.
|
|
386
686
|
|
|
387
687
|
## Final operating rule
|
|
388
688
|
|
|
389
|
-
When Prisma PHP behavior is documented locally, read the relevant
|
|
689
|
+
When Prisma PHP behavior is documented locally, read the relevant current doc first and follow it.
|
|
390
690
|
|
|
391
691
|
Do not guess.
|
|
392
692
|
|