create-prisma-php-app 5.0.0-alpha.7 → 5.1.0-alpha.0

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.
@@ -0,0 +1,142 @@
1
+ # Project Guidelines
2
+
3
+ ## Source Of Truth
4
+
5
+ - Use `./prisma-php.json` as the single source of truth for which optional Prisma PHP features are enabled in the current app and which framework-managed scaffolds should exist.
6
+ - For Prisma PHP applications, treat `node_modules/prisma-php/dist/docs/index.md` as the entry point for the installed framework version.
7
+ - Treat `node_modules/prisma-php/dist/docs` as framework reference docs that teach AI how Prisma PHP works. The presence of a page in that docs folder does not mean the current workspace has that feature enabled.
8
+ - Read the matching doc in `node_modules/prisma-php/dist/docs` before generating or editing framework-specific Prisma PHP code.
9
+ - Expect `AGENTS.md` in the project root and keep it aligned with the installed Prisma PHP docs contract.
10
+ - In the Prisma PHP package source repo, keep `AGENTS.md`, `.github/copilot-instructions.md`, any `.github/instructions/**/*.instructions.md`, and `dist/docs` aligned so the published docs remain correct after install.
11
+ - Do not assume installed consumer apps also ship a root `.github/copilot-instructions.md` unless the generator explicitly creates one.
12
+ - If `.github/instructions/**/*.instructions.md` exists, treat those files as workspace-local task instructions for third-party libraries, component systems, icon packs, and other implementation-specific rules.
13
+ - Before generating or editing code, inspect `.github/instructions/` and read any `*.instructions.md` files that match the current task, named library, target files, or implementation surface.
14
+ - 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.
15
+ - When a task maps to an optional feature such as `backendOnly`, `swaggerDocs`, `typescript`, `websocket`, or `mcp`, inspect `./prisma-php.json` first, then read the matching docs page to learn the implementation contract.
16
+ - When docs and project files still leave a runtime gap, inspect the narrow core file that owns the behavior: `TemplateCompiler.php` for HTML fragment compilation and route root scoping, `ImportComponent.php` for imported partials, `MainLayout.php` for metadata and head/footer scripts, `PrismaPHPSettings.php` plus generated settings JSON for component and route maps, `Request.php` for request handling, `Validator.php`/`Rule.php` for validation, and feature-specific files such as `UploadFile.php`, `Mailer.php`, or `Streaming/SSE.php`.
17
+
18
+ ## Workspace Task Instructions
19
+
20
+ - Treat `.github/instructions/**/*.instructions.md` as an optional task-specific extension of the Prisma PHP docs contract.
21
+ - Use those instruction files when the task mentions a library, pattern, or file surface they cover, such as a PHPXUI component library, `ppicons`, or another workspace-specific integration.
22
+ - Keep `./prisma-php.json` as the source of truth for Prisma PHP feature flags and generated scaffolds; use `.github/instructions/**/*.instructions.md` to refine task-specific implementation details and prefer the most specific matching instruction when more than one applies.
23
+ - When generating or updating PHP `use` imports for components from the same namespace or generated library directory, prefer grouped imports once a file needs two or more symbols, such as `use Lib\PPIcons\{ArrowRight, Mail};` or `use Lib\PHPXUI\{Badge, Button};`.
24
+ - Single imports remain fine when only one component is needed, and existing separate imports do not need style-only cleanup unless the task asks for it.
25
+
26
+ ## Project Structure Recommendations
27
+
28
+ - Keep `src/app` focused on route files, layouts, handlers, and route-scoped partials.
29
+ - Prefer `src/Components` for reusable application UI components shared across pages or layouts.
30
+ - Keep reusable non-UI code such as services, auth, middleware, Prisma classes, and helpers in `src/Lib`.
31
+ - Treat `./public/uploads` as the default local public upload directory for file uploads.
32
+ - Treat generated component libraries such as `src/Lib/PHPXUI` and `src/Lib/PPIcons` as library-specific surfaces governed by their manifests and `.github/instructions/*.instructions.md` files.
33
+ - If a partial starts as route-local but becomes shared across the app, move it from `src/app` to `src/Components`.
34
+ - Suggest this structure by default when helping users organize growing Prisma PHP apps.
35
+
36
+ ## Component Tag Contract
37
+
38
+ - Class-based PHPX components and generated icon components are consumed with HTML-first `x-` tags from `settings/component-map.json`, such as `<x-alert>` or `<x-search />`.
39
+ - Use the `tagName` entries in `settings/component-map.json` as the supported runtime contract for component and icon markup.
40
+ - Do not invent `x-` tag names from PHP class names when the generated map exists; inspect `settings/component-map.json`.
41
+ - Keep documentation, examples, and generated code focused on the current `x-` tag contract.
42
+ - Author component attributes in kebab-case. The runtime hydrates kebab-case names into camelCase component props and public PHPX properties, such as `as-child` -> `asChild` and `close-on-escape-key` -> `closeOnEscapeKey`.
43
+ - Use mustache values for reactive props, such as `selected-date="{selectedDate}"` and `on-date-select="{setSelectedDate}"`.
44
+ - Write component examples as HTML-first Prisma PHP markup using the current `x-` tag contract.
45
+
46
+ ## Framework-Managed Package Scripts
47
+
48
+ - Prisma PHP can generate `package.json` scripts for BrowserSync, Tailwind, TypeScript, WebSocket, MCP, Swagger docs, and related helpers.
49
+ - Prefer `npm run dev` for ordinary local development and `npm run build` for ordinary production-style asset builds.
50
+ - 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.
51
+ - 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.
52
+ - Use `npm run create-swagger-docs` only when Swagger or OpenAPI output must be intentionally generated or refreshed.
53
+ - 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.
54
+
55
+ ## BrowserSync URL Source Of Truth
56
+
57
+ - When AI needs to test or confirm whether a route, server response, or proxy-backed request is working, use `./settings/bs-config.json` as the source of truth for the current BrowserSync URLs.
58
+ - Do not assume the proxy stays on the default `http://localhost:5090`; if that port is busy, the active BrowserSync ports may change.
59
+ - Prefer confirming the current `local`, `external`, `ui`, and `uiExternal` values in `./settings/bs-config.json` before suggesting a test URL or opening the app in the browser.
60
+ - Use this file when frontend console errors or terminal output suggest the wrong local URL, proxy port, or BrowserSync UI port is being used during debugging.
61
+
62
+ ## File Upload Defaults
63
+
64
+ - For local public uploads, default to `./public/uploads`.
65
+ - In PHP examples and generated code, use `PUBLIC_PATH . '/uploads/'` or the equivalent absolute `./public/uploads` path.
66
+ - Treat files in `./public/uploads` as publicly accessible from the app's public web root.
67
+ - Keep `./settings/bs-config.ts` aligned with `const PUBLIC_IGNORE_DIRS = ["uploads"];` so upload writes, renames, replacements, and deletes do not trigger BrowserSync reloads.
68
+ - Do not document or generate legacy local upload directories such as `DOCUMENT_PATH . '/uploads/'`, a project-root `/uploads`, or `src/uploads`.
69
+ - There is no backward-compatible or legacy local upload directory in this guidance.
70
+
71
+ ## CLI Command Alignment
72
+
73
+ - For new apps, prefer `npx create-prisma-php-app <project-name>` as the default recommended create command.
74
+ - For existing apps, prefer `npx pp update project` after saving feature changes in `prisma-php.json`.
75
+ - When an existing app needs a specific release channel or pinned update version, prefer `npx pp update project --tag <value>` or `npx pp update project --tag=<value>`.
76
+ - Use `--tag <value>` or `--tag=<value>` for release-channel or pinned-version updates.
77
+ - Do not use `npx pp update project` as a substitute for Prisma ORM migration commands.
78
+
79
+ ## Authentication Route Strategy
80
+
81
+ - Prisma PHP defaults to public routes.
82
+ - Choose the route privacy strategy at the start of the app, before creating most routes.
83
+ - If the app will have many public pages, keep the public-default strategy.
84
+ - If the app will have only a few public entry points and most routes should require login, use the private-default strategy.
85
+ - For private-default routing, enable both `IS_ALL_ROUTES_PRIVATE = true` and `IS_TOKEN_AUTO_REFRESH = true` in `src/Lib/Auth/AuthConfig.php`.
86
+ - When `IS_ALL_ROUTES_PRIVATE` is `true`, Prisma PHP treats routes as private by default and uses `publicRoutes` for the public allowlist; home is already public by default because `publicRoutes` starts as `['/']`.
87
+ - Keep `authRoutes` public by default unless the user explicitly asks to change them.
88
+ - There is no need to modify other Prisma PHP core files for this route privacy behavior.
89
+ - If `src/Lib/Auth/AuthConfig.php` is customized, preserve it during future Prisma PHP project updates by adding `./src/Lib/Auth/AuthConfig.php` to `excludeFiles` in `prisma-php.json`.
90
+
91
+ ## PulsePoint-First Frontend Rules
92
+
93
+ - In full-stack Prisma PHP apps, treat PulsePoint as the primary JavaScript authoring model for frontend behavior.
94
+ - For page-local interactivity, prefer `index.php` or nested `layout.php` with a plain inline `<script>` that contains PulsePoint state and functions directly, and use `pp.fetchFunction(...)` for backend calls.
95
+ - Do not wrap inline PulsePoint code in `DOMContentLoaded`, IIFEs, manual `pp.mount()` calls, or custom scoping/bootstrap helpers. Prisma PHP scopes the component boundary and runs the script for you.
96
+ - Reserve plain browser JavaScript or TypeScript modules for reusable helpers in `ts/`, third-party libraries, low-level browser APIs, or behavior that does not belong inside a PulsePoint component boundary.
97
+ - Use `pp-style` for template-driven inline CSS, `pp-spread="{...attrs}"` for dynamic attribute objects, `pp-for` only on `<template>`, and plain `key` for keyed diffing.
98
+ - Use `pp.ref(...)`, `pp-ref`, `pp.portal(...)`, `pp.createContext(...)`, `Context.Provider`, and `pp.context(...)` according to `pulsepoint.md`.
99
+ - Use `value`, `defaultvalue`, and `defaultchecked` form bindings according to `pulsepoint.md`; do not author internal `data-pp-*` runtime attributes.
100
+
101
+ ## Route File Conventions
102
+
103
+ - 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.
104
+ - `index.php` and nested `layout.php` must render a single parent HTML element. Treat that root like a React-style component boundary rather than loose sibling markup.
105
+ - For pages and nested layouts, author a plain single root element and let Prisma PHP inject the PulsePoint `pp-component` scope automatically.
106
+ - Author plain `<script>` tags inside that root when PulsePoint is needed. Put the PulsePoint code at the top level of that script. Do not manually add `type="text/pp"`, `DOMContentLoaded` wrappers, IIFEs, or manual bootstrap code; Prisma PHP normalizes the script contract for the runtime.
107
+ - Only the root `layout.php` should define `<html>`, `<head>`, and `<body>`. When PulsePoint is present, keep `MainLayout::$children;` and any `<script>` inside one clear wrapper.
108
+
109
+ ## Component Boundary Rules
110
+
111
+ - Distinguish PHPX class components from `ImportComponent` partials.
112
+ - `ImportComponent` partials must output exactly one root element because Prisma PHP uses that root as the imported component boundary and serializes props there.
113
+ - Do not manually add `pp-component` inside `ImportComponent` partial source; Prisma PHP injects it there.
114
+ - When imported partials need PulsePoint logic, keep the `<script>` inside that same root element and author it as a plain `<script>` tag without `type="text/pp"`, DOM-ready wrappers, or manual bootstrap code.
115
+
116
+ ## Relevant Docs
117
+
118
+ - Project structure and feature placement: `dist/docs/project-structure.md`
119
+ - CLI project creation and update commands: `dist/docs/commands.md`
120
+ - First-time project installation and local setup: `dist/docs/installation.md`
121
+ - Existing-project upgrades and feature refreshes: `dist/docs/upgrading.md`
122
+ - TypeScript frontend tooling, the `typescript` flag, and `ts/main.ts` registration: `dist/docs/typescript.md`
123
+ - Backend-only API usage and `backendOnly`: `dist/docs/backend-only.md`
124
+ - Route and layout structure: `dist/docs/layouts-and-pages.md`
125
+ - AI integration, provider-backed chat, streaming, and MCP boundary: `dist/docs/get-started-ia.md`
126
+ - Data loading, `#[Exposed]`, and SSE streaming: `dist/docs/fetching-data.md`
127
+ - Bootstrap flow, runtime init order, request initialization, and function-call protection: `dist/docs/bootstrap-runtime.md`
128
+ - PulsePoint runtime rules: `dist/docs/pulsepoint.md`
129
+ - Component and `ImportComponent` rules: `dist/docs/components.md`
130
+ - Cache behavior and `CacheHandler`: `dist/docs/caching.md`
131
+ - Validation rules: `dist/docs/validator.md`
132
+ - Prisma ORM schema, migrations, and generated PHP classes: `dist/docs/prisma-php-orm.md`
133
+ - Environment variables and `PP\Env` usage: `dist/docs/env.md`
134
+ - File uploads and file manager behavior: `dist/docs/file-manager.md`
135
+ - Email and SMTP workflows: `dist/docs/email.md`
136
+ - WebSocket and realtime behavior: `dist/docs/websocket.md`
137
+ - MCP server and tool rules: `dist/docs/mcp.md`
138
+ - Authentication: `dist/docs/authentication.md`
139
+ - Error handling, expected failures, and route error files: `dist/docs/error-handling.md`
140
+ - Metadata and icons: `dist/docs/metadata-and-og-images.md`
141
+ - API-style handlers and webhooks: `dist/docs/route-handlers.md`
142
+ - Swagger/OpenAPI generation and `swaggerDocs`: `dist/docs/swagger-docs.md`