prisma-php 0.0.12 → 0.0.13

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.
@@ -5,9 +5,19 @@
5
5
  - For Prisma PHP applications, treat `node_modules/prisma-php/dist/docs/index.md` as the entry point for the installed framework version.
6
6
  - Read the matching doc in `node_modules/prisma-php/dist/docs` before generating or editing framework-specific Prisma PHP code.
7
7
  - Expect `AGENTS.md` in the project root and keep it aligned with the installed Prisma PHP docs contract.
8
- - When updating Prisma PHP package/docs sources in this repo, keep `AGENTS.md`, `.github/copilot-instructions.md`, and `dist/docs` aligned so the published docs remain correct after install.
8
+ - In the Prisma PHP package source repo, keep `AGENTS.md`, `.github/copilot-instructions.md`, and `dist/docs` aligned so the published docs remain correct after install.
9
+ - Do not assume installed consumer apps also ship a root `.github/copilot-instructions.md` unless the generator explicitly creates one.
9
10
  - Keep every `dist/docs/*.md` page AI-discoverable on its own: the frontmatter description and opening section should clearly say when agents should read that file and which adjacent docs to consult next.
10
11
 
12
+ ## Framework-Managed Package Scripts
13
+
14
+ - Prisma PHP can generate `package.json` scripts for BrowserSync, Tailwind, TypeScript, WebSocket, MCP, Swagger docs, and related helpers.
15
+ - Prefer `npm run dev` for ordinary local development and `npm run build` for ordinary production-style asset builds.
16
+ - 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 orchestrated through the generated top-level scripts.
17
+ - 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.
18
+ - Use `npm run create-swagger-docs` only when Swagger or OpenAPI output must be intentionally generated or refreshed.
19
+ - When package-script behavior matters, read `dist/docs/commands.md` first and inspect the actual `package.json` in the target project before assuming which scripts exist.
20
+
11
21
  ## Route File Conventions
12
22
 
13
23
  - For PulsePoint-aware `index.php` and nested `layout.php`, keep file order as PHP first, then one parent HTML element; keep the PulsePoint `<script>` as the last child inside that same root element.
@@ -33,7 +33,7 @@ Do not assume another framework’s auth abstractions apply directly.
33
33
 
34
34
  ## Read this doc when you need
35
35
 
36
- - **route privacy defaults, `AuthConfig.php`, JWT session lifecycle, `Auth::signIn(...)`, `Auth::signOut(...)`, `refreshUserSession(...)`, route RBAC, or provider overview** → official `auth-get-started`
36
+ - **route privacy defaults, `AuthConfig.php`, JWT session lifecycle, `Auth::getInstance()->signIn(...)`, `Auth::getInstance()->signOut(...)`, `Auth::getInstance()->refreshUserSession(...)`, route RBAC, or provider overview** → official `auth-get-started`
37
37
  - **email/password registration, login, password hashing, CSRF-aware credential flow, or user/role schema design** → official `credentials`
38
38
  - **social login, provider credentials, callback route handling, account linking, or OAuth account schema** → official `state-manager-auth`
39
39
 
@@ -45,9 +45,9 @@ The official docs describe these major concepts:
45
45
 
46
46
  - `AuthConfig.php` is the central place for defining route protection strategy and role-based route rules
47
47
  - sessions are managed through Prisma PHP auth helpers rather than ad hoc cookie code
48
- - `Auth::signIn(...)` creates the session payload
49
- - `Auth::signOut(...)` ends the session and can redirect
50
- - `refreshUserSession(...)` updates the active session payload when user permissions or profile data change
48
+ - `Auth::getInstance()->signIn(...)` creates the session payload
49
+ - `Auth::getInstance()->signOut(...)` ends the session and can redirect
50
+ - `Auth::getInstance()->refreshUserSession(...)` updates the active session payload when user permissions or profile data change
51
51
  - route-level RBAC and function-level access control are separate but complementary concerns
52
52
 
53
53
  ## Security strategy
@@ -88,24 +88,24 @@ Mental model:
88
88
 
89
89
  ### Sign in
90
90
 
91
- Use `Auth::signIn(...)` after credentials or provider identity are validated.
91
+ Use `Auth::getInstance()->signIn(...)` after credentials or provider identity are validated.
92
92
 
93
93
  The session payload should contain the user data your app needs for identity and authorization decisions, commonly including:
94
94
 
95
95
  - `id`
96
96
  - `role`
97
97
 
98
- Do not invent a separate session writer when the framework already documents `Auth::signIn(...)`.
98
+ Do not invent a separate session writer when the framework already documents `Auth::getInstance()->signIn(...)`.
99
99
 
100
100
  ### Sign out
101
101
 
102
- Use `Auth::signOut(...)` to destroy the session and invalidate the client cookie.
102
+ Use `Auth::getInstance()->signOut(...)` to destroy the session and invalidate the client cookie.
103
103
 
104
104
  When the flow needs a post-logout redirect, use the documented redirect argument instead of custom manual cookie clearing.
105
105
 
106
106
  ### Live session refresh
107
107
 
108
- Use `refreshUserSession(...)` when a currently signed-in user’s auth payload must change immediately, such as:
108
+ Use `Auth::getInstance()->refreshUserSession(...)` when a currently signed-in user’s auth payload must change immediately, such as:
109
109
 
110
110
  - role promotion or demotion
111
111
  - profile data updates included in the auth payload
@@ -157,7 +157,7 @@ When backend functions are protected with `#[Exposed(allowedRoles: [...])]`, kee
157
157
 
158
158
  The credentials docs describe the classic email/password flow as a full-stack Prisma PHP pattern where backend logic and form UI can live together in route files.
159
159
 
160
- ### Schema expectations
160
+ ### Provider schema expectations
161
161
 
162
162
  For credentials auth, the docs show a user model with fields such as:
163
163
 
@@ -185,7 +185,7 @@ The documented login flow uses:
185
185
  - a route such as `src/app/auth/login/index.php`
186
186
  - a user lookup through Prisma ORM
187
187
  - `password_verify(...)` for password comparison
188
- - `Auth::signIn(...)` with the session payload
188
+ - `Auth::getInstance()->signIn(...)` with the session payload
189
189
  - a redirect after successful sign-in
190
190
 
191
191
  ### Validation rule
@@ -95,7 +95,7 @@ For backend-only apps, the default route file should stay explicit and small:
95
95
  <?php
96
96
 
97
97
  use Lib\Prisma\Classes\Prisma;
98
- use PP\Header\Boom;
98
+ use PP\Headers\Boom;
99
99
  use PP\Request;
100
100
 
101
101
  if (!Request::$isGet) {
@@ -0,0 +1,145 @@
1
+ ---
2
+ title: Bootstrap and Runtime
3
+ description: Learn how Prisma PHP bootstraps requests, initializes runtime helpers, resolves routes, and protects function calls with cookies and FUNCTION_CALL_SECRET.
4
+ related:
5
+ title: Related docs
6
+ description: Use env for configuration, fetching-data for exposed functions, and error-handling for runtime failures.
7
+ links:
8
+ - /docs/env
9
+ - /docs/fetching-data
10
+ - /docs/error-handling
11
+ - /docs/project-structure
12
+ ---
13
+
14
+ This page explains the Prisma PHP runtime bootstrap flow used by the current project scaffold.
15
+
16
+ If a task involves request initialization, route resolution, local-store callbacks, `FUNCTION_CALL_SECRET`, `prisma_php_csrf`, or the order in which Prisma PHP runtime helpers are initialized, AI agents should read this page first and keep generated code aligned with `bootstrap.php`.
17
+
18
+ ## AI rule: read the bootstrap docs first
19
+
20
+ Before changing runtime bootstrap behavior, use this order:
21
+
22
+ 1. Read `prisma-php.json`.
23
+ 2. Read `env.md` for runtime configuration values.
24
+ 3. Read this page for init order, request protection, and route resolution.
25
+ 4. Read `fetching-data.md` when the task also involves `#[Exposed]` functions or streamed responses.
26
+ 5. Inspect `bootstrap.php` only when the docs still leave a gap.
27
+
28
+ ## Runtime init order
29
+
30
+ The current Prisma PHP bootstrap initializes the runtime in this order:
31
+
32
+ 1. `date_default_timezone_set(Env::string('APP_TIMEZONE', 'UTC'))`
33
+ 2. `PrismaPHPSettings::init()`
34
+ 3. `Request::init()`
35
+ 4. `StateManager::init()`
36
+ 5. `MainLayout::init()`
37
+ 6. `ErrorHandler::registerHandlers()`
38
+ 7. set the `pp_local_store_key` cookie from `PrismaPHPSettings::$localStoreKey`
39
+ 8. create or validate the `prisma_php_csrf` cookie
40
+ 9. resolve the current route, included content file, and active layouts
41
+ 10. run auth checks and fatal-error checks
42
+
43
+ When AI changes bootstrap-sensitive code, preserve that ordering unless the task is explicitly about changing the framework runtime.
44
+
45
+ ## What `PrismaPHPSettings::init()` loads
46
+
47
+ The runtime reads Prisma PHP project settings from these files:
48
+
49
+ - `prisma-php.json`
50
+ - `settings/files-list.json`
51
+ - `settings/class-imports.json`
52
+ - `settings/request-data.json`
53
+
54
+ It also derives the local storage callback key from `LOCALSTORE_KEY` in the environment, normalized to a lowercase underscore-separated value.
55
+
56
+ ## Request initialization
57
+
58
+ `Request::init()` normalizes the current request into the Prisma PHP request model.
59
+
60
+ That initialization populates:
61
+
62
+ - HTTP method flags such as `Request::$isGet`, `Request::$isPost`, and `Request::$isDelete`
63
+ - unified request parameters through `Request::$params`
64
+ - dynamic route parameters through `Request::$dynamicParams`
65
+ - local storage values through `Request::$localStorage`
66
+ - request metadata such as `Request::$uri`, `Request::$pathname`, `Request::$documentUrl`, and `Request::$requestedWith`
67
+
68
+ Do not invent a second request abstraction when the task already fits the current `PP\Request` model.
69
+
70
+ ## Route resolution and layout collection
71
+
72
+ The bootstrap resolves the active content file from the incoming request URI and then collects matching layouts.
73
+
74
+ Important runtime rules:
75
+
76
+ - `AuthMiddleware::handle($pathname)` runs during route resolution
77
+ - grouped routes and dynamic routes are resolved before falling back to root precedence
78
+ - the root layout is collected first when it exists
79
+ - nested layouts are collected from the route tree
80
+ - `files-list.json` is read by the runtime, but consumer-app code should not edit it manually
81
+
82
+ For route creation or route placement, continue using `project-structure.md`, `layouts-and-pages.md`, and `route-handlers.md`.
83
+
84
+ ## Local store callback contract
85
+
86
+ Prisma PHP reserves a browser callback channel for local storage synchronization.
87
+
88
+ The runtime sets a `pp_local_store_key` cookie using `PrismaPHPSettings::$localStoreKey`.
89
+
90
+ When the incoming `HTTP_X_PP_FUNCTION` header matches that local store key, Prisma PHP treats the request as a local-store callback and validates the CSRF token before returning JSON.
91
+
92
+ Do not replace that flow with a custom local storage callback protocol unless the task is explicitly about changing the framework runtime.
93
+
94
+ ## Function-call CSRF contract
95
+
96
+ Prisma PHP protects callback-style requests with a CSRF token signed by `FUNCTION_CALL_SECRET`.
97
+
98
+ ### `FUNCTION_CALL_SECRET`
99
+
100
+ `FUNCTION_CALL_SECRET` is required for CSRF protection.
101
+
102
+ If it is missing, bootstrap throws a runtime exception instead of silently disabling protection.
103
+
104
+ ### `prisma_php_csrf`
105
+
106
+ The runtime stores the CSRF token in the `prisma_php_csrf` cookie.
107
+
108
+ The token format is:
109
+
110
+ - `nonce.signature`
111
+
112
+ The signature is an HMAC-SHA256 hash of the nonce using `FUNCTION_CALL_SECRET`.
113
+
114
+ If the cookie is missing or invalid, bootstrap generates a new token.
115
+
116
+ ### Validation rules
117
+
118
+ Protected callback-style requests must send an `X-CSRF-TOKEN` header that exactly matches the `prisma_php_csrf` cookie.
119
+
120
+ Validation fails when:
121
+
122
+ - the secret is missing
123
+ - the header is missing
124
+ - the cookie is missing
125
+ - the header and cookie do not match
126
+ - the cookie format is invalid
127
+ - the HMAC signature does not validate
128
+
129
+ For these failures, bootstrap returns a JSON error response instead of allowing the callback to continue.
130
+
131
+ ## Runtime guidance for AI agents
132
+
133
+ - when changing `.env` values related to runtime behavior, read `env.md` first
134
+ - when working on `#[Exposed]` functions, fetch callbacks, or streams, combine this page with `fetching-data.md`
135
+ - when the task touches route selection, layout wrapping, or route file choice, combine this page with `project-structure.md` and `layouts-and-pages.md`
136
+ - when runtime failures are expected, combine this page with `error-handling.md`
137
+ - do not remove or bypass `FUNCTION_CALL_SECRET`, `prisma_php_csrf`, or `pp_local_store_key` unless the task explicitly changes the security model
138
+
139
+ ## Good to know
140
+
141
+ - Prisma PHP bootstrap initializes `MainLayout` before route files are rendered
142
+ - Prisma PHP bootstrap initializes `ErrorHandler` before runtime inclusion continues
143
+ - `PP\Request` is the normalized request source of truth
144
+ - `pp_local_store_key` and `prisma_php_csrf` are runtime cookies managed by bootstrap
145
+ - `FUNCTION_CALL_SECRET` is required for callback CSRF protection
@@ -92,13 +92,13 @@ This flag enables non-interactive mode.
92
92
 
93
93
  Instead of stopping for terminal prompts, the CLI proceeds with the provided flags and default values.
94
94
 
95
- ### Use this when
95
+ #### When to use `-y`
96
96
 
97
97
  - running automation or CI
98
98
  - scaffolding quickly without prompts
99
99
  - generating predictable output from scripts
100
100
 
101
- ### Example
101
+ #### `-y` example
102
102
 
103
103
  ```bash package="npm"
104
104
  npx create-prisma-php-app my-app -y
@@ -112,13 +112,13 @@ Creates a backend-only project.
112
112
 
113
113
  This is appropriate for API-first or server-only applications where the project should center on handler-style routes instead of the usual full-stack page flow.
114
114
 
115
- ### Use this when
115
+ #### When to use `--backend-only`
116
116
 
117
117
  - building REST APIs
118
118
  - creating server-only services
119
119
  - building a backend for a separate frontend client
120
120
 
121
- ### Example
121
+ #### `--backend-only` example
122
122
 
123
123
  ```bash package="npm"
124
124
  npx create-prisma-php-app my-app --backend-only
@@ -130,13 +130,13 @@ Enables Swagger and OpenAPI documentation support.
130
130
 
131
131
  This prepares the project for API schema generation and API documentation workflows.
132
132
 
133
- ### Use this when
133
+ #### When to use `--swagger-docs`
134
134
 
135
135
  - documenting API endpoints
136
136
  - sharing API contracts with frontend or third-party consumers
137
137
  - generating OpenAPI-based tooling from the project
138
138
 
139
- ### Example
139
+ #### `--swagger-docs` example
140
140
 
141
141
  ```bash package="npm"
142
142
  npx create-prisma-php-app my-app --backend-only --swagger-docs
@@ -148,13 +148,13 @@ Enables Tailwind CSS support.
148
148
 
149
149
  This prepares frontend styling with Tailwind-related files and scripts.
150
150
 
151
- ### Use this when
151
+ #### When to use `--tailwindcss`
152
152
 
153
153
  - building dashboards or admin panels
154
154
  - creating a styled full-stack UI
155
155
  - starting a project that should use utility-first CSS from day one
156
156
 
157
- ### Example
157
+ #### `--tailwindcss` example
158
158
 
159
159
  ```bash package="npm"
160
160
  npx create-prisma-php-app my-app --tailwindcss
@@ -168,13 +168,13 @@ When this flag is enabled, Prisma PHP should keep frontend TypeScript in the roo
168
168
 
169
169
  Read `typescript.md` for the TypeScript-specific workflow.
170
170
 
171
- ### Use this when
171
+ #### When to use `--typescript`
172
172
 
173
173
  - you want typed frontend code
174
174
  - you want stronger editor tooling for frontend work
175
175
  - your project will include frontend TypeScript assets
176
176
 
177
- ### Example
177
+ #### `--typescript` example
178
178
 
179
179
  ```bash package="npm"
180
180
  npx create-prisma-php-app my-app --typescript
@@ -186,13 +186,13 @@ Enables WebSocket support.
186
186
 
187
187
  This prepares the project for real-time server and client workflows.
188
188
 
189
- ### Use this when
189
+ #### When to use `--websocket`
190
190
 
191
191
  - building chat systems
192
192
  - creating live dashboards
193
193
  - sending notifications or push-style realtime updates
194
194
 
195
- ### Example
195
+ #### `--websocket` example
196
196
 
197
197
  ```bash package="npm"
198
198
  npx create-prisma-php-app my-app --websocket
@@ -204,13 +204,13 @@ Enables MCP support.
204
204
 
205
205
  This prepares the project for Model Context Protocol server and tool workflows.
206
206
 
207
- ### Use this when
207
+ #### When to use `--mcp`
208
208
 
209
209
  - integrating AI tooling
210
210
  - exposing tools through MCP
211
211
  - building model-connected workflows
212
212
 
213
- ### Example
213
+ #### `--mcp` example
214
214
 
215
215
  ```bash package="npm"
216
216
  npx create-prisma-php-app my-app --mcp
@@ -222,13 +222,13 @@ Enables Prisma ORM support.
222
222
 
223
223
  This prepares the project for database-backed development and ORM generation workflows.
224
224
 
225
- ### Use this when
225
+ #### When to use `--prisma`
226
226
 
227
227
  - your project needs a database
228
228
  - you want Prisma ORM available from the start
229
229
  - you are building CRUD apps, APIs, dashboards, or content systems
230
230
 
231
- ### Example
231
+ #### `--prisma` example
232
232
 
233
233
  ```bash package="npm"
234
234
  npx create-prisma-php-app my-app --prisma
@@ -242,7 +242,7 @@ Shows the starter kits available in the installed CLI version.
242
242
 
243
243
  Use this before choosing a starter if you want to inspect the currently supported templates.
244
244
 
245
- ### Example
245
+ #### `--list-starter-kits` example
246
246
 
247
247
  ```bash package="npm"
248
248
  npx create-prisma-php-app --list-starter-kits
@@ -256,7 +256,7 @@ Starter kits provide opinionated starting points so you do not have to assemble
256
256
 
257
257
  The exact built-in starter kit names depend on the installed CLI version, so `--list-starter-kits` is the safest way to confirm the current list.
258
258
 
259
- ### Example
259
+ #### `--starter-kit=<kit>` example
260
260
 
261
261
  ```bash package="npm"
262
262
  npx create-prisma-php-app my-app --starter-kit=basic
@@ -268,7 +268,7 @@ Uses a custom external starter kit source.
268
268
 
269
269
  This is intended for custom or team-managed boilerplates and is typically paired with `--starter-kit=custom`.
270
270
 
271
- ### Example
271
+ #### `--starter-kit-source=<url>` example
272
272
 
273
273
  ```bash package="npm"
274
274
  npx create-prisma-php-app my-app --starter-kit=custom --starter-kit-source=https://github.com/user/repo
@@ -314,7 +314,7 @@ Use this when the project already exists and you want to regenerate or refresh f
314
314
 
315
315
  If you are enabling or changing features on an existing project, update `prisma-php.json` first, then run `npx pp update project`.
316
316
 
317
- ### Example
317
+ #### `npx pp update project` example
318
318
 
319
319
  ```bash package="npm"
320
320
  npx pp update project
@@ -324,7 +324,7 @@ npx pp update project
324
324
 
325
325
  Refreshes the current project using the latest published version of `create-prisma-php-app`.
326
326
 
327
- ### Example
327
+ #### `npx pp update project @latest` example
328
328
 
329
329
  ```bash package="npm"
330
330
  npx pp update project @latest
@@ -334,13 +334,13 @@ npx pp update project @latest
334
334
 
335
335
  Refreshes the project using a tagged prerelease such as an alpha build.
336
336
 
337
- ### Use this when
337
+ #### When to use `npx pp update project @v5-alpha`
338
338
 
339
339
  - testing prerelease framework changes
340
340
  - validating upcoming CLI behavior
341
341
  - trying an experimental version on an existing project
342
342
 
343
- ### Example
343
+ #### `npx pp update project @v5-alpha` example
344
344
 
345
345
  ```bash package="npm"
346
346
  npx pp update project @v5-alpha
@@ -350,13 +350,13 @@ npx pp update project @v5-alpha
350
350
 
351
351
  Refreshes the project using a fixed package version.
352
352
 
353
- ### Use this when
353
+ #### When to use `npx pp update project @1.2.3`
354
354
 
355
355
  - you need reproducible updates
356
356
  - you want to stay on a known working version
357
357
  - you want strict version control over generator behavior
358
358
 
359
- ### Example
359
+ #### `npx pp update project @1.2.3` example
360
360
 
361
361
  ```bash package="npm"
362
362
  npx pp update project @1.2.3
@@ -368,13 +368,13 @@ Runs the update in non-interactive mode.
368
368
 
369
369
  This skips the confirmation prompt and proceeds directly.
370
370
 
371
- ### Use this when
371
+ #### When to use `npx pp update project -y`
372
372
 
373
373
  - running scripted updates
374
374
  - using CI or automation
375
375
  - updating from AI-driven workflows
376
376
 
377
- ### Example
377
+ #### `npx pp update project -y` example
378
378
 
379
379
  ```bash package="npm"
380
380
  npx pp update project -y
@@ -401,6 +401,135 @@ It is not a substitute for Prisma ORM schema migration commands.
401
401
 
402
402
  If your database schema changed, use the Prisma ORM workflow documented in `prisma-php-orm.md` and `upgrading.md`.
403
403
 
404
+ ## Prisma PHP Node Script Execution Guide
405
+
406
+ This section documents the generated Node script surface in Prisma PHP apps.
407
+
408
+ For normal Prisma PHP work, prefer the top-level entry points:
409
+
410
+ - `npm run dev` during development
411
+ - `npm run build` when you intentionally want a production-style asset build
412
+
413
+ Prisma PHP wires feature-specific scripts such as Tailwind, TypeScript, WebSocket, and MCP into those top-level commands when the matching feature is enabled.
414
+
415
+ That means AI agents should not default to telling users to run `npm run tailwind`, `npm run tailwind:build`, `npm run ts:watch`, or `npm run ts:build` after ordinary file changes. Those lower-level scripts are mainly useful when isolating one part of the toolchain, debugging, or running a feature-specific workflow on purpose.
416
+
417
+ ### Script table
418
+
419
+ | Command | Type | What it does | When it exists | Use case |
420
+ | --- | --- | --- | --- | --- |
421
+ | `npm run projectName` | npm script | Runs `tsx settings/project-name.ts` so project name metadata stays aligned with the generated app setup. | Always added to generated `package.json`. | Internal setup step used before the main dev pipeline. |
422
+ | `npm run browserSync` | npm script | Runs `tsx settings/bs-config.ts` to start BrowserSync with the generated project config. | Always added. | Local development server and live reload. |
423
+ | `npm run browserSync:build` | npm script | Runs `tsx settings/build.ts` as the build-oriented BrowserSync step. | Always added. | Included in the normal build pipeline. |
424
+ | `npm run dev` | npm script | Runs `npm-run-all projectName -p browserSync ...` and adds feature-specific watch processes when those features are enabled. | Always added, but the parallel subtasks depend on enabled features. | Main local development command. |
425
+ | `npm run build` | npm script | Runs `npm-run-all ...` with build-oriented tasks such as `browserSync:build`, and optionally Tailwind and TypeScript build steps. | Always added, but included subtasks depend on enabled features. | Main build command for preparing project assets. |
426
+ | `npm run tailwind` | npm script | Runs `postcss src/app/globals.css -o public/css/styles.css --watch`. | Only when `tailwindcss` is enabled. | Feature-specific CSS watch mode when you need to isolate styling work. |
427
+ | `npm run tailwind:build` | npm script | Runs `postcss src/app/globals.css -o public/css/styles.css`. | Only when `tailwindcss` is enabled. | Feature-specific CSS build step, usually reached through `npm run build`. |
428
+ | `npm run ts:watch` | npm script | Runs `vite build --watch`. | Only when `typescript` is enabled and the project is not backend-only. | Feature-specific frontend TypeScript watch mode. |
429
+ | `npm run ts:build` | npm script | Runs `vite build`. | Only when `typescript` is enabled and the project is not backend-only. | Feature-specific frontend bundle step, usually reached through `npm run build`. |
430
+ | `npm run websocket` | npm script | Runs `tsx settings/restart-websocket.ts`. | Only when `websocket` is enabled. | Start or restart the WebSocket runtime in projects that use realtime features. |
431
+ | `npm run mcp` | npm script | Runs `tsx settings/restart-mcp.ts`. | Only when `mcp` is enabled. | Start or restart the MCP runtime in projects that expose MCP tools. |
432
+ | `npm run create-swagger-docs` | npm script | Runs the Prisma PHP Swagger docs generation flow and can optionally receive model names. | Only when `swaggerDocs` is enabled. | Generate or refresh Swagger and OpenAPI output. |
433
+ | `npx create-prisma-php-app <project-name>` | npx command | Creates a Prisma PHP project, installs dependencies, writes files, and saves the selected feature flags. | Available from the create CLI. | Scaffold a new project. |
434
+ | `npx create-prisma-php-app --list-starter-kits` | npx command | Prints the starter kits supported by the installed CLI version. | Always available in the create CLI. | Inspect available templates before choosing one. |
435
+ | `npx pp update project` | npx command | Reads `prisma-php.json` in the current app and refreshes the project using that saved configuration. | Available from the update CLI. | Refresh an existing project after saving feature changes or when updating framework-managed files. |
436
+ | `npx pp update project @latest` | npx command | Updates the current project using the latest published generator version. | Available from the update CLI. | Move an existing project to the newest published generator behavior. |
437
+ | `npx pp update project @v5-alpha` | npx command | Updates the current project using a tagged prerelease version such as an alpha build. | Available from the update CLI. | Test prerelease generator changes. |
438
+ | `npx pp update project @1.2.3` | npx command | Updates the current project using a fixed package version. | Available from the update CLI. | Use a pinned generator version for reproducible updates. |
439
+ | `npx pp update project -y` | npx command | Runs the update flow in non-interactive mode. | Available from the update CLI. | CI, scripts, or AI-driven update workflows. |
440
+
441
+ ## How `npm run dev` is composed
442
+
443
+ `npm run dev` is generated around this base shape:
444
+
445
+ - `npm-run-all projectName -p browserSync ...conditional-watchers`
446
+
447
+ Possible parallel watchers added to `dev` are:
448
+
449
+ - `tailwind`
450
+ - `ts:watch`
451
+ - `websocket`
452
+ - `mcp`
453
+
454
+ That means:
455
+
456
+ - the base dev flow always includes `projectName` and `browserSync`
457
+ - Tailwind projects also run `tailwind`
458
+ - TypeScript frontend projects also run `ts:watch`
459
+ - WebSocket projects also run `websocket`
460
+ - MCP projects also run `mcp`
461
+
462
+ ### Example `dev` combinations
463
+
464
+ | Project features | Resulting dev command shape |
465
+ | --- | --- |
466
+ | Minimal project | `npm-run-all projectName -p browserSync` |
467
+ | Tailwind only | `npm-run-all projectName -p browserSync tailwind` |
468
+ | Tailwind + TypeScript | `npm-run-all projectName -p browserSync tailwind ts:watch` |
469
+ | Tailwind + TypeScript + WebSocket + MCP | `npm-run-all projectName -p browserSync tailwind ts:watch websocket mcp` |
470
+
471
+ ## How `npm run build` is composed
472
+
473
+ `npm run build` is generated from:
474
+
475
+ - base: `browserSync:build`
476
+ - plus `tailwind:build` when Tailwind is enabled
477
+ - plus `ts:build` when TypeScript is enabled and the project is not backend-only
478
+
479
+ ### Example `build` combinations
480
+
481
+ | Project features | Resulting build command shape |
482
+ | --- | --- |
483
+ | Minimal project | `npm-run-all browserSync:build` |
484
+ | Tailwind only | `npm-run-all tailwind:build browserSync:build` |
485
+ | Tailwind + TypeScript | `npm-run-all ts:build tailwind:build browserSync:build` |
486
+ | TypeScript only | `npm-run-all ts:build browserSync:build` |
487
+
488
+ ## Common execution examples
489
+
490
+ ### Development
491
+
492
+ ```bash package="npm"
493
+ npm run dev
494
+ npm run browserSync
495
+ npm run tailwind
496
+ npm run ts:watch
497
+ npm run websocket
498
+ npm run mcp
499
+ ```
500
+
501
+ ### Build
502
+
503
+ ```bash package="npm"
504
+ npm run build
505
+ npm run browserSync:build
506
+ npm run tailwind:build
507
+ npm run ts:build
508
+ npm run create-swagger-docs
509
+ ```
510
+
511
+ ### Project scaffolding and update
512
+
513
+ ```bash package="npm"
514
+ npx create-prisma-php-app my-app
515
+ npx create-prisma-php-app my-app --tailwindcss --typescript --prisma
516
+ npx create-prisma-php-app --list-starter-kits
517
+
518
+ npx pp update project
519
+ npx pp update project @latest
520
+ npx pp update project @v5-alpha
521
+ npx pp update project @1.2.3
522
+ npx pp update project -y
523
+ ```
524
+
525
+ ## Execution notes
526
+
527
+ - `npm run tailwind`, `npm run tailwind:build`, `npm run ts:watch`, `npm run ts:build`, `npm run websocket`, `npm run mcp`, and `npm run create-swagger-docs` are conditional scripts. They only exist when the matching feature was enabled for the project.
528
+ - For ordinary Prisma PHP development, start with `npm run dev` instead of manually running each watcher one by one.
529
+ - For ordinary build preparation, start with `npm run build` instead of manually running `tailwind:build` or `ts:build` unless you intentionally want to isolate those steps.
530
+ - `npx pp update project` rebuilds the update command from the saved `prisma-php.json` configuration, so you do not need to retype every feature flag.
531
+ - `npx pp update project` is a project refresh command, not an ORM migration shortcut.
532
+
404
533
  ## Recommended mental model
405
534
 
406
535
  ### Use create when
@@ -238,7 +238,7 @@ Typical shape:
238
238
 
239
239
  namespace Lib\Components;
240
240
 
241
- use Lib\PHPX\PHPX;
241
+ use PP\PHPX\PHPX;
242
242
 
243
243
  class ClassName extends PHPX
244
244
  {
@@ -429,7 +429,7 @@ If you need explicit control over raw SSE event metadata, Prisma PHP also includ
429
429
  Core locations in Prisma PHP:
430
430
 
431
431
  ```txt
432
- vendor/tsnc/prisma-php/src/SSE.php
432
+ vendor/tsnc/prisma-php/src/Streaming/SSE.php
433
433
  vendor/tsnc/prisma-php/src/Streaming/ServerSentEvent.php
434
434
  ```
435
435
 
@@ -12,7 +12,7 @@ related:
12
12
 
13
13
  Use this page as the routing entry point for the local Prisma PHP docs. If a task involves choosing which Prisma PHP guide to read before generating framework-specific code, start here and then jump to the matching page in `node_modules/prisma-php/dist/docs`.
14
14
 
15
- Before generating framework-specific code, read `prisma-php.json` first, then the matching local docs page. For auth read `authentication.md`; for env read `env.md`; for uploads read `file-manager.md`; for email read `email.md`; for websocket read `websocket.md`; for MCP read `mcp.md`; for ORM read `prisma-php-orm.md`; for reactive UI read `pulsepoint.md`; for validation read `validator.md`; for data loading read `fetching-data.md`; and for route or layout structure read `layouts-and-pages.md`.
15
+ Before generating framework-specific code, read `prisma-php.json` first, then the matching local docs page. For auth read `authentication.md`; for env read `env.md`; for runtime bootstrap and request protection read `bootstrap-runtime.md`; for uploads read `file-manager.md`; for email read `email.md`; for websocket read `websocket.md`; for MCP read `mcp.md`; for ORM read `prisma-php-orm.md`; for reactive UI read `pulsepoint.md`; for validation read `validator.md`; for data loading read `fetching-data.md`; and for route or layout structure read `layouts-and-pages.md`.
16
16
 
17
17
  Welcome to the Prisma PHP documentation!
18
18
 
@@ -36,8 +36,9 @@ Use this order:
36
36
 
37
37
  1. Read `./prisma-php.json` first.
38
38
  2. Read the relevant local docs in `node_modules/prisma-php/dist/docs`.
39
- 3. Inspect local project files.
40
- 4. Inspect `vendor/tsnc/prisma-php/src` only when framework internals are necessary.
39
+ 3. Read `bootstrap-runtime.md` when runtime init, cookies, request routing, or function-call protection matter.
40
+ 4. Inspect local project files.
41
+ 5. Inspect `vendor/tsnc/prisma-php/src` only when framework internals are necessary.
41
42
 
42
43
  ### Default interactive pattern
43
44
 
@@ -116,12 +117,13 @@ Do not confuse the route-file pattern with the `ImportComponent` partial pattern
116
117
  ### Read this doc when you need
117
118
 
118
119
  - **project setup or file placement** → `project-structure.md`
119
- - **CLI project creation, starter kits, create-prisma-php-app flags, or project update commands** → `commands.md`
120
+ - **CLI project creation, starter kits, create-prisma-php-app flags, project update commands, or generated `package.json` scripts** → `commands.md`
120
121
  - **backend-only Prisma PHP usage, API-first projects, `backendOnly`, CORS, separate frontend clients, or choosing `route.php` as the default route file** → `backend-only.md`
121
122
  - **pages, layouts, route creation, nested routes, or PulsePoint-aware `index.php` and `layout.php` structure** → `layouts-and-pages.md`
122
123
  - **PHPX components, props, children, fragments, icons, buttons, accordions, or component composition** → `components.md`
123
124
  - **frontend TypeScript tooling, the `typescript` flag, the `ts/` directory, `ts/main.ts`, npm packages, or registered browser helpers used from template expressions and PulsePoint scripts** → `typescript.md`
124
125
  - **environment variables, `.env`, `PP\Env`, `Env::get(...)`, `Env::string(...)`, `Env::bool(...)`, `Env::int(...)`, or runtime configuration** → `env.md`
126
+ - **bootstrap, request initialization, `FUNCTION_CALL_SECRET`, `prisma_php_csrf`, `pp_local_store_key`, route resolution, or runtime init order** → `bootstrap-runtime.md`
125
127
  - **file uploads, `multipart/form-data`, `$_FILES`, `PP\FileManager\UploadFile`, rename/delete flows, file replacement, allowed file types, upload size rules, or file manager pages** → `file-manager.md`
126
128
  - **AI integration, provider SDKs, chat UIs, streamed assistant responses, or deciding between page-local AI features, websocket, and MCP** → `get-started-ia.md`
127
129
  - **SMTP setup, `.env` mail variables, `PP\PHPMailer\Mailer`, HTML email, text email, recipients, reply-to, CC, BCC, or attachments** → `email.md`
@@ -149,6 +151,7 @@ Do not confuse the route-file pattern with the `ImportComponent` partial pattern
149
151
  - do not create, edit, or maintain `files-list.json`; Prisma PHP generates route listings automatically
150
152
  - when the project is API-first or backend-only, read `backend-only.md`, inspect `backendOnly` in `prisma-php.json`, and default to `route.php` for normal route behavior
151
153
  - when reading runtime configuration, `.env`, or feature flags, read `env.md` first and prefer `PP\Env` typed helpers over repeated manual parsing
154
+ - when the task involves request bootstrap, cookie setup, route resolution, or function-call security, read `bootstrap-runtime.md` before reasoning from generic PHP request habits
152
155
  - when building interactive frontend behavior, prefer the documented PulsePoint pattern with browser-side reactive state and `pp.fetchFunction(...)` for server calls; treat this as the default unless the user explicitly asks for a PHP-only interaction pattern
153
156
  - when the task involves frontend TypeScript tooling or registered browser helpers, read `typescript.md`, keep reusable module code in `ts/`, and call the registered globals from PulsePoint component scripts instead of placing `import` or `export` inside inline route scripts
154
157
  - when building PulsePoint inside `index.php` or `layout.php`, read `layouts-and-pages.md` together with `pulsepoint.md`, use one parent route root, put `pp-component` on that root, and keep the `<script>` inside it as the last child
@@ -158,6 +161,7 @@ Do not confuse the route-file pattern with the `ImportComponent` partial pattern
158
161
  - when building backend validation logic, read `validator.md` first, then use the route-specific docs for the request entry point
159
162
  - when using `pp.fetchFunction(...)`, expose the PHP function explicitly with `#[Exposed]`
160
163
  - when changing feature flags, update `prisma-php.json` first, then follow the documented update workflow
164
+ - when package scripts matter, read `commands.md`, prefer `npm run dev` for ordinary local development, prefer `npm run build` for intentional production-style asset builds, and do not default to lower-level Tailwind or TypeScript scripts after routine file changes
161
165
  - when the task involves OpenAPI or Swagger generation, read `swagger-docs.md`, inspect `swaggerDocs` in `prisma-php.json`, and keep the generated spec path and config file aligned with the Prisma PHP workflow
162
166
  - when building reusable PHPX components, read `components.md` first
163
167
  - when building file-upload flows, file listings, rename/delete actions, or a file manager screen, read `file-manager.md` first and keep the implementation aligned with Prisma PHP’s documented File Manager model
@@ -191,6 +195,8 @@ Use `typescript.md` as the local AI guide for:
191
195
  - installing npm packages for frontend utilities
192
196
  - using registered helpers from template expressions and PulsePoint scripts while keeping inline component scripts as plain JavaScript
193
197
 
198
+ For ordinary local work in a TypeScript-enabled app, prefer `npm run dev` instead of defaulting to `npm run ts:watch` directly.
199
+
194
200
  ## Env
195
201
 
196
202
  Prisma PHP includes a documented environment helper centered on `PP\Env`, which reads already-loaded runtime values and exposes typed accessors for strings, booleans, and integers.
@@ -291,9 +297,9 @@ Use `authentication.md` as the local AI-awareness guide for:
291
297
 
292
298
  - `AuthConfig.php`
293
299
  - public-default vs private-default route strategy
294
- - `Auth::signIn(...)`
295
- - `Auth::signOut(...)`
296
- - `refreshUserSession(...)`
300
+ - `Auth::getInstance()->signIn(...)`
301
+ - `Auth::getInstance()->signOut(...)`
302
+ - `Auth::getInstance()->refreshUserSession(...)`
297
303
  - route-level RBAC
298
304
  - function-level protection with `#[Exposed(allowedRoles: [...])]`
299
305
  - credential authentication
@@ -35,3 +35,7 @@ npx create-prisma-php-app@latest my-app
35
35
  cd my-app
36
36
  npm run dev
37
37
  ```
38
+
39
+ For ordinary Prisma PHP local development, `npm run dev` is the main entry point.
40
+
41
+ Do not default to running lower-level generated scripts such as Tailwind or TypeScript watchers one by one unless you intentionally need to isolate part of the toolchain.
@@ -160,21 +160,27 @@ For example, to create a root layout:
160
160
  <?php
161
161
 
162
162
  use PP\MainLayout;
163
+
164
+ MainLayout::$title = !empty(MainLayout::$title) ? MainLayout::$title : 'Create Prisma PHP App';
165
+ MainLayout::$description = !empty(MainLayout::$description) ? MainLayout::$description : 'Generated by create Prisma PHP App';
166
+
163
167
  ?>
164
168
 
165
- <!DOCTYPE html>
166
169
  <html lang="en">
170
+
167
171
  <head>
168
- <meta charset="UTF-8">
169
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
170
- <title><?= htmlspecialchars(MainLayout::$title ?: 'My Prisma PHP App') ?></title>
171
- <meta name="description" content="<?= htmlspecialchars(MainLayout::$description ?: 'Default application description') ?>">
172
+ <!-- Dynamic Meta Tags -->
173
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
174
+ <!-- Dynamic Header Scripts -->
175
+ <link href="/css/styles.css" rel="stylesheet" />
176
+ <script type="module" src="/js/main.js"></script>
172
177
  </head>
173
- <body>
174
- <main>
175
- <?= MainLayout::$children; ?>
176
- </main>
178
+
179
+ <body pp-spa="true" style="opacity:0;pointer-events:none;user-select:none;transition:opacity .18s ease-out;">
180
+ <?= MainLayout::$children; ?>
181
+ <!-- Dynamic Footer Scripts -->
177
182
  </body>
183
+
178
184
  </html>
179
185
  ```
180
186
 
package/dist/docs/mcp.md CHANGED
@@ -330,6 +330,10 @@ php src/Lib/MCP/mcp-server.php
330
330
 
331
331
  The official docs also note that some Prisma PHP setups start MCP during `npm run dev`. AI should inspect local scripts before assuming that behavior in a specific project.
332
332
 
333
+ That means AI should not default to telling users to run `npm run mcp` after ordinary application changes.
334
+
335
+ Use the dedicated MCP runtime command only when you intentionally need to start or debug MCP separately from the normal development flow.
336
+
333
337
  If the defaults are unchanged, the endpoint is:
334
338
 
335
339
  ```txt
@@ -24,7 +24,7 @@ If a task involves page titles, descriptions, custom meta tags, favicon files, i
24
24
  Before generating Prisma PHP metadata code, use this order:
25
25
 
26
26
  1. Use `MainLayout::$title` and `MainLayout::$description` for document metadata.
27
- 2. Use `MainLayout::addCustomMetaData(...)` for extra meta tags.
27
+ 2. Use `MainLayout::addCustomMetadata(...)` for extra meta tags.
28
28
  3. Keep visible headings separate from document metadata when the UI text needs to differ.
29
29
  4. Use the documented `favicon`, `icon`, and `apple-icon` file conventions instead of inventing generated metadata modules.
30
30
  5. Read `layouts-and-pages.md` when the task also changes route or layout structure.
@@ -40,11 +40,11 @@ Prisma PHP uses this to manage head scripts, footer scripts, and custom metadata
40
40
  ```php filename="src/app/products/index.php"
41
41
  <?php
42
42
 
43
- use Lib\MainLayout;
43
+ use PP\MainLayout;
44
44
 
45
45
  MainLayout::$title = "My Awesome Page";
46
46
  MainLayout::$description = "This is a description of my awesome page";
47
- MainLayout::addCustomMetaData("author", "John Doe");
47
+ MainLayout::addCustomMetadata("author", "John Doe");
48
48
  ?>
49
49
  ```
50
50
 
@@ -52,7 +52,7 @@ In this model:
52
52
 
53
53
  - `MainLayout::$title` sets the page title
54
54
  - `MainLayout::$description` sets the page description
55
- - `MainLayout::addCustomMetaData(...)` adds additional metadata such as `author` or other `<meta>` values
55
+ - `MainLayout::addCustomMetadata(...)` adds additional metadata such as `author` or other `<meta>` values
56
56
 
57
57
  ## Heading text vs document metadata
58
58
 
@@ -63,7 +63,7 @@ This is a better pattern than relying on a local `$title` variable alone:
63
63
  ```php filename="src/app/dashboard/index.php"
64
64
  <?php
65
65
 
66
- use Lib\MainLayout;
66
+ use PP\MainLayout;
67
67
 
68
68
  MainLayout::$title = "Dashboard";
69
69
  MainLayout::$description = "View account stats, recent activity, and important actions.";
@@ -85,8 +85,8 @@ The docs show metadata being generated from request parameters:
85
85
  ```php filename="src/app/product/index.php"
86
86
  <?php
87
87
 
88
- use Lib\MainLayout;
89
- use Lib\Request;
88
+ use PP\MainLayout;
89
+ use PP\Request;
90
90
 
91
91
  $productName = Request::$params->productName ?? '';
92
92
  $productDescription = Request::$params->productDescription ?? '';
@@ -107,7 +107,7 @@ That means this pattern is correct:
107
107
  ```php filename="src/app/about/index.php"
108
108
  <?php
109
109
 
110
- use Lib\MainLayout;
110
+ use PP\MainLayout;
111
111
 
112
112
  MainLayout::$title = "About Us";
113
113
  MainLayout::$description = "Learn more about our company.";
@@ -126,22 +126,28 @@ Your root `layout.php` can read from `MainLayout` so page-level metadata set in
126
126
  ```php filename="src/app/layout.php"
127
127
  <?php
128
128
 
129
- use Lib\MainLayout;
129
+ use PP\MainLayout;
130
+
131
+ MainLayout::$title = !empty(MainLayout::$title) ? MainLayout::$title : 'Create Prisma PHP App';
132
+ MainLayout::$description = !empty(MainLayout::$description) ? MainLayout::$description : 'Generated by create Prisma PHP App';
133
+
130
134
  ?>
131
135
 
132
- <!DOCTYPE html>
133
136
  <html lang="en">
137
+
134
138
  <head>
135
- <meta charset="UTF-8">
136
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
137
- <title><?= htmlspecialchars(MainLayout::$title ?: "My Prisma PHP App") ?></title>
138
- <meta name="description" content="<?= htmlspecialchars(MainLayout::$description ?: "Default application description") ?>">
139
+ <!-- Dynamic Meta Tags -->
140
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
141
+ <!-- Dynamic Header Scripts -->
142
+ <link href="/css/styles.css" rel="stylesheet" />
143
+ <script type="module" src="/js/main.js"></script>
139
144
  </head>
140
- <body>
141
- <main>
142
- <?= MainLayout::$children; ?>
143
- </main>
145
+
146
+ <body pp-spa="true" style="opacity:0;pointer-events:none;user-select:none;transition:opacity .18s ease-out;">
147
+ <?= MainLayout::$children; ?>
148
+ <!-- Dynamic Footer Scripts -->
144
149
  </body>
150
+
145
151
  </html>
146
152
  ```
147
153
 
@@ -149,17 +155,17 @@ This lets route files control SEO metadata while the root layout stays responsib
149
155
 
150
156
  ## Adding custom metadata
151
157
 
152
- You can attach additional custom metadata through `MainLayout::addCustomMetaData(...)`.
158
+ You can attach additional custom metadata through `MainLayout::addCustomMetadata(...)`.
153
159
 
154
160
  ```php filename="src/app/blog/index.php"
155
161
  <?php
156
162
 
157
- use Lib\MainLayout;
163
+ use PP\MainLayout;
158
164
 
159
165
  MainLayout::$title = "Blog";
160
166
  MainLayout::$description = "Latest articles and product updates.";
161
- MainLayout::addCustomMetaData("keywords", "blog, updates, articles");
162
- MainLayout::addCustomMetaData("author", "Prisma PHP Team");
167
+ MainLayout::addCustomMetadata("keywords", "blog, updates, articles");
168
+ MainLayout::addCustomMetadata("author", "Prisma PHP Team");
163
169
  ?>
164
170
  ```
165
171
 
@@ -184,7 +190,7 @@ Example:
184
190
  ```php filename="src/app/index.php"
185
191
  <?php
186
192
 
187
- use Lib\MainLayout;
193
+ use PP\MainLayout;
188
194
 
189
195
  MainLayout::addHeadScript('<script src="head-script.js"></script>');
190
196
  MainLayout::addFooterScript('<script src="footer-script.js"></script>');
@@ -195,9 +201,11 @@ This is not metadata in the strict SEO sense, but it is part of the same page-he
195
201
 
196
202
  ## Favicon, icon, and apple-icon
197
203
 
198
- Prisma PHP also documents file conventions for application icons.
204
+ For the current generated Prisma PHP scaffold, the verified built-in icon pattern is the standard favicon link in the root layout.
205
+
206
+ If you use additional icon assets such as `icon` or `apple-icon`, treat them as application assets and wire the matching `<link>` tags explicitly unless your project adds a higher-level convention.
199
207
 
200
- The docs say that `favicon`, `icon`, and `apple-icon` files let you define icons that appear in places such as:
208
+ Those assets can still be used for places such as:
201
209
 
202
210
  - browser tabs
203
211
  - phone home screens
@@ -213,40 +221,40 @@ The provided Prisma PHP icon docs mention image-file based usage such as:
213
221
 
214
222
  ### Where to place them
215
223
 
216
- The docs say to place a `favicon`, `icon`, or `apple-icon` file within your `/app` directory, and specifically state that the favicon image must be located at the **top level** of `/app`.
224
+ In generated Prisma PHP projects, place `favicon.ico` in the public web root. In the default scaffold that file lives at `public/favicon.ico` and is served at `/favicon.ico`.
217
225
 
218
226
  ## `favicon.ico`
219
227
 
220
- For the favicon, the docs say to add a `favicon.ico` image file to the root `/app` route segment. They also note that the favicon link tag is already included in the `<head>` of `layout.php`, so the normal step is simply to replace the existing `favicon.ico` file with your own.
228
+ For the favicon, the generated layout already includes a standard link tag, so the normal step is simply to replace the existing `public/favicon.ico` file with your own.
221
229
 
222
230
  The documented link tag is:
223
231
 
224
232
  ```php
225
- <link rel="icon" href="<?= Request::baseUrl?>/favicon.ico" type="image/x-icon" sizes="16x16">
233
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
226
234
  ```
227
235
 
228
- This means Prisma PHP already expects the favicon in the standard project location and wires it into the layout automatically.
236
+ This means Prisma PHP already expects the favicon in the public web root and wires it into the layout automatically.
229
237
 
230
- ## Automatic head integration
238
+ ## Head integration
231
239
 
232
- The icon docs say Prisma PHP evaluates these icon files and **automatically adds the appropriate tags to your app’s `<head>` element**.
240
+ In the current scaffold, the verified automatic head integration is the built-in favicon link already present in the root layout.
233
241
 
234
- That is the Prisma PHP equivalent of file-convention-based icon metadata.
242
+ This metadata page does not claim automatic `icon` or `apple-icon` tag generation because that behavior is not demonstrated by the current local scaffold or runtime sources.
235
243
 
236
244
  ## Metadata and icons in a full page example
237
245
 
238
246
  ```php filename="src/app/products/[slug]/index.php"
239
247
  <?php
240
248
 
241
- use Lib\MainLayout;
249
+ use PP\MainLayout;
242
250
  use PP\Request;
243
251
 
244
252
  $slug = Request::$dynamicParams['slug'] ?? 'product';
245
253
 
246
254
  MainLayout::$title = "Product: " . ucfirst((string) $slug);
247
255
  MainLayout::$description = "View product details for " . ucfirst((string) $slug) . ".";
248
- MainLayout::addCustomMetaData("author", "Prisma PHP");
249
- MainLayout::addCustomMetaData("keywords", "product, ecommerce, details");
256
+ MainLayout::addCustomMetadata("author", "Prisma PHP");
257
+ MainLayout::addCustomMetadata("keywords", "product, ecommerce, details");
250
258
  ?>
251
259
 
252
260
  <section>
@@ -263,10 +271,10 @@ If you are coming from Next.js, the closest mapping is:
263
271
 
264
272
  | Next.js idea | Prisma PHP equivalent |
265
273
  | --------------------------------- | -------------------------------------------------------------------------------------- |
266
- | `export const metadata = { ... }` | `MainLayout::$title`, `MainLayout::$description`, `MainLayout::addCustomMetaData(...)` |
274
+ | `export const metadata = { ... }` | `MainLayout::$title`, `MainLayout::$description`, `MainLayout::addCustomMetadata(...)` |
267
275
  | `generateMetadata()` | dynamic metadata set at runtime in the PHP route file |
268
- | `favicon.ico` in app conventions | `favicon.ico` in the app root with built-in layout support |
269
- | file-based icon conventions | Prisma PHP `favicon`, `icon`, `apple-icon` file conventions |
276
+ | `favicon.ico` in app conventions | `public/favicon.ico` served at `/favicon.ico` with built-in layout support |
277
+ | file-based icon conventions | application-managed icon assets and explicit `<link>` tags when needed |
270
278
  | generated OG image files | not documented on the provided Prisma PHP metadata pages |
271
279
 
272
280
  The main difference is that Prisma PHP’s documented system is **layout-class driven** for metadata and **file-convention driven** for icons, rather than based on exported metadata objects or generated route modules.
@@ -276,7 +284,7 @@ The main difference is that Prisma PHP’s documented system is **layout-class d
276
284
  The Next.js page title includes OG images, but the provided Prisma PHP docs you linked focus on:
277
285
 
278
286
  - dynamic page metadata through `MainLayout`
279
- - icon file conventions such as `favicon`, `icon`, and `apple-icon`
287
+ - favicon support in the generated layout and optional additional icon assets when the app explicitly links them
280
288
 
281
289
  Because those pages do not document a dedicated Prisma PHP Open Graph image generation system, this page does **not** invent one. If your framework later adds a specific OG image convention, that would belong here.
282
290
 
@@ -284,9 +292,9 @@ Because those pages do not document a dedicated Prisma PHP Open Graph image gene
284
292
 
285
293
  - Prisma PHP uses `MainLayout` for dynamic metadata management.
286
294
  - `MainLayout::$title` and `MainLayout::$description` are the main documented page metadata properties.
287
- - `MainLayout::addCustomMetaData(...)` adds custom metadata such as `author`.
295
+ - `MainLayout::addCustomMetadata(...)` adds custom metadata such as `author`.
288
296
  - Metadata should be set before any HTML output.
289
297
  - `MainLayout::addHeadScript(...)` and `MainLayout::addFooterScript(...)` can inject scripts into the page shell.
290
- - Prisma PHP supports `favicon`, `icon`, and `apple-icon` file conventions.
291
- - `favicon.ico` belongs at the top level of the app directory.
292
- - Prisma PHP automatically adds the appropriate icon tags to the document head.
298
+ - the generated Prisma PHP scaffold includes built-in favicon support through the root layout.
299
+ - `favicon.ico` belongs in the public web root and is served as `/favicon.ico` in the default scaffold.
300
+ - additional icon assets should be linked explicitly unless your app adds its own higher-level icon convention.
@@ -18,6 +18,8 @@ If a task involves file placement, feature flags, route creation, or overall Pri
18
18
 
19
19
  For AI-assisted work, treat `node_modules/prisma-php/dist/docs` as the installed Prisma PHP docs location for the active project version, and keep `AGENTS.md` in the project root aligned with that docs set.
20
20
 
21
+ For installed consumer apps, treat root `AGENTS.md` as the documented workspace instruction file. If the Prisma PHP package source repo also contains `.github/copilot-instructions.md`, treat that as package-maintainer guidance rather than a second consumer-app instruction file.
22
+
21
23
  ## AI rule: read the structure docs first
22
24
 
23
25
  Before generating Prisma PHP files or folders, use this order:
@@ -25,9 +27,10 @@ Before generating Prisma PHP files or folders, use this order:
25
27
  1. Read `prisma-php.json`.
26
28
  2. Read the matching installed doc in `node_modules/prisma-php/dist/docs`.
27
29
  3. Read `AGENTS.md` for project-specific Prisma PHP rules.
28
- 4. Decide whether the task belongs in `src/app`, `src/Lib`, `prisma`, `public`, `settings`, or the installed docs path.
29
- 5. Create routes from the route tree instead of editing `files-list.json`.
30
- 6. Use `layouts-and-pages.md`, `route-handlers.md`, or `components.md` once the file location is known.
30
+ 4. When runtime bootstrap, request initialization, cookies, or function-call protection matter, read `bootstrap-runtime.md`.
31
+ 5. Decide whether the task belongs in `src/app`, `src/Lib`, `prisma`, `public`, `settings`, or the installed docs path.
32
+ 6. Create routes from the route tree instead of editing `files-list.json`.
33
+ 7. Use `layouts-and-pages.md`, `route-handlers.md`, or `components.md` once the file location is known.
31
34
 
32
35
  ## Folder and file conventions
33
36
 
@@ -61,7 +64,7 @@ These files are typically used to configure the app, manage dependencies, and de
61
64
  | File | Purpose |
62
65
  | ---------------------- | -------------------------------------------------------------- |
63
66
  | `composer.json` | PHP dependencies and autoloading |
64
- | `package.json` | Frontend tooling and development scripts when used |
67
+ | `package.json` | Frontend tooling and framework-managed scripts when used |
65
68
  | `.env` | Environment variables |
66
69
  | `AGENTS.md` | Project-root AI guidance aligned with the installed docs set |
67
70
  | `prisma/schema.prisma` | Main Prisma schema file |
@@ -90,6 +93,15 @@ Typical values include:
90
93
 
91
94
  If an AI agent is working on the project, it should inspect `prisma-php.json` before deciding whether Tailwind CSS, TypeScript, Prisma ORM, Swagger docs, MCP, or websocket-related code should be generated.
92
95
 
96
+ When package-script behavior matters, inspect `package.json` and read `commands.md` before suggesting how local tooling should be started.
97
+
98
+ For normal project work, Prisma PHP usually expects:
99
+
100
+ - `npm run dev` as the top-level local development entry point
101
+ - `npm run build` as the top-level production-style asset build entry point
102
+
103
+ Do not default to lower-level scripts such as Tailwind, TypeScript, WebSocket, or MCP commands after routine code changes unless you intentionally need to isolate that part of the workflow.
104
+
93
105
  For backend-only API projects, read `backend-only.md`.
94
106
 
95
107
  For Swagger and OpenAPI generation, read `swagger-docs.md`.
@@ -120,6 +132,8 @@ Only prefer a more PHP-only interaction pattern when the user explicitly asks fo
120
132
 
121
133
  Some files in a Prisma PHP project are framework-managed and should not be manually maintained as part of normal route work.
122
134
 
135
+ That same idea applies to generated package scripts in `package.json`: they are part of the framework-managed project workflow, so AI should not treat every lower-level script as the default thing the user needs to run after each change.
136
+
123
137
  ### `files-list.json`
124
138
 
125
139
  Prisma PHP automatically generates the route list in `files-list.json`.
@@ -151,7 +151,7 @@ In Prisma PHP, a common pattern is to guard the HTTP method at the top of the fi
151
151
  <?php
152
152
 
153
153
  use PP\Request;
154
- use PP\Header\Boom;
154
+ use PP\Headers\Boom;
155
155
  use Lib\Prisma\Classes\Prisma;
156
156
 
157
157
  if (!Request::$isGet) {
@@ -235,7 +235,7 @@ You can also use `route.php` for form submissions or API-style POST endpoints.
235
235
  use PP\Request;
236
236
  use PP\Rule;
237
237
  use PP\Validator;
238
- use PP\Header\Boom;
238
+ use PP\Headers\Boom;
239
239
 
240
240
  if (!Request::$isPost) {
241
241
  Boom::methodNotAllowed()->toResponse();
@@ -34,10 +34,14 @@ Before enabling or regenerating Swagger docs, use this order:
34
34
 
35
35
  1. Inspect `prisma-php.json` for `swaggerDocs` and `backendOnly`.
36
36
  2. Read `backend-only.md`, `route-handlers.md`, and `prisma-php-orm.md` as needed for the surrounding API workflow.
37
- 3. Use `npm run create-swagger-docs` for the documented generation flow.
37
+ 3. Use `npm run create-swagger-docs` for the documented on-demand generation flow.
38
38
  4. Inspect `settings/prisma-schema-config.json` before changing output paths or generation modes.
39
39
  5. Do not treat Swagger generation as a substitute for ORM migrations or route implementation.
40
40
 
41
+ Unlike generated Tailwind or TypeScript build/watch scripts, Swagger generation is not the normal framework-managed step that runs as part of everyday `npm run dev` or `npm run build` work.
42
+
43
+ AI agents should treat `npm run create-swagger-docs` as an explicit documentation or contract-generation action and run it only when Swagger output actually needs to be created or refreshed.
44
+
41
45
  ## When Swagger docs are worth enabling
42
46
 
43
47
  Enable Swagger docs when you need a stable machine-readable contract for the API.
@@ -80,6 +84,10 @@ That JSON file is the handoff point for tools such as:
80
84
 
81
85
  Prisma PHP's Swagger workflow supports generating documentation for models from `schema.prisma`.
82
86
 
87
+ Use this command intentionally when your OpenAPI output needs to be updated.
88
+
89
+ Do not confuse it with framework-managed development scripts such as `npm run dev` or asset build orchestration through `npm run build`.
90
+
83
91
  ```bash package="npm"
84
92
  npm run create-swagger-docs
85
93
  npm run create-swagger-docs Order
@@ -135,7 +143,7 @@ For API-oriented Prisma PHP work, a practical Swagger workflow is:
135
143
 
136
144
  1. update `schema.prisma`
137
145
  2. run the normal ORM workflow when the schema changed
138
- 3. regenerate Swagger docs
146
+ 3. regenerate Swagger docs only when the contract output needs to be refreshed
139
147
  4. inspect `src/app/swagger-docs/apis/pphp-swagger.json`
140
148
  5. regenerate external clients if the contract changed
141
149
 
@@ -75,6 +75,13 @@ npx pp update project -y
75
75
 
76
76
  For broader project refresh guidance, read `upgrading.md`.
77
77
 
78
+ After TypeScript scaffolding exists, ordinary local work should still start from the framework-managed entry points:
79
+
80
+ - `npm run dev` for normal development
81
+ - `npm run build` when you intentionally want a production-style asset build
82
+
83
+ Do not default to `npm run ts:watch` or `npm run ts:build` after routine TypeScript edits unless you intentionally need to isolate the frontend bundle step.
84
+
78
85
  ## The `ts/` directory
79
86
 
80
87
  For organization and reuse, keep frontend TypeScript logic in the root `ts/` directory.
@@ -47,6 +47,17 @@ npx pp update project -y
47
47
 
48
48
  This ensures the update process applies the correct files, dependencies, and project structure for the features you selected.
49
49
 
50
+ For feature flags such as `tailwindcss`, `typescript`, `websocket`, and `mcp`, the updater's job is to refresh the generated files and scripts that the framework expects.
51
+
52
+ After that, AI agents should not default to telling users to manually run each feature-specific package script one by one.
53
+
54
+ For ordinary local verification after an update, prefer:
55
+
56
+ - `npm run dev` for the normal development workflow
57
+ - `npm run build` when you intentionally want a production-style asset build
58
+
59
+ Use lower-level scripts such as Tailwind, TypeScript, WebSocket, or MCP commands only when isolating a specific part of the toolchain, debugging, or running a feature-specific workflow on purpose.
60
+
50
61
  If the feature you are enabling is API-focused, read `backend-only.md` for `backendOnly` usage and `swagger-docs.md` for `swaggerDocs` generation workflow details.
51
62
 
52
63
  ## Typical upgrade flow
@@ -155,7 +166,7 @@ After updating your project, verify the following:
155
166
 
156
167
  - Your enabled features in `prisma-php.json` match the current project requirements.
157
168
  - Dependencies installed correctly.
158
- - Local development still runs as expected.
169
+ - Local development still runs as expected, normally through `npm run dev` rather than individual watcher scripts.
159
170
  - Any custom files listed in `excludeFiles` were preserved.
160
171
  - Database and generated ORM classes are in sync if schema changes were included.
161
172
 
@@ -84,6 +84,10 @@ The broader Prisma PHP project structure docs also show a development helper tha
84
84
 
85
85
  - `settings/restart-websocket.ts`
86
86
 
87
+ Some Prisma PHP setups also wire websocket restart behavior into `npm run dev`.
88
+
89
+ AI should inspect the current `package.json` before telling users to run `npm run websocket` manually, and should prefer the normal development flow unless websocket startup needs to be isolated or debugged on purpose.
90
+
87
91
  Important casing rule:
88
92
 
89
93
  The official page may show lowercase path examples such as `src/lib/websocket`, but Prisma PHP project structure docs use `src/Lib`, and this repo's guidance expects application libraries under `src/Lib`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-php",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Prisma PHP tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {