prisma-php 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/01-getting-started/authentication.md +280 -0
- package/dist/docs/01-getting-started/caching.md +346 -0
- package/dist/docs/01-getting-started/components.md +589 -0
- package/dist/docs/01-getting-started/error-handling.md +359 -0
- package/dist/docs/01-getting-started/fetching-data.md +637 -0
- package/dist/docs/01-getting-started/file-manager.md +307 -0
- package/dist/docs/01-getting-started/index.md +142 -0
- package/dist/docs/01-getting-started/installation.md +18 -0
- package/dist/docs/01-getting-started/layouts-and-pages.md +289 -0
- package/dist/docs/01-getting-started/metadata-and-og-images.md +228 -0
- package/dist/docs/01-getting-started/prisma-php-orm.md +374 -0
- package/dist/docs/01-getting-started/project-structure.md +328 -0
- package/dist/docs/01-getting-started/pulsepoint.md +434 -0
- package/dist/docs/01-getting-started/route-handlers.md +344 -0
- package/dist/docs/01-getting-started/upgrading.md +172 -0
- package/dist/docs/index.md +243 -0
- package/package.json +16 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: File Manager
|
|
3
|
+
description: Learn how Prisma PHP file uploads and file management work so AI agents can build upload forms, manage storage safely, and use the documented UploadFile workflow instead of inventing custom file-handling patterns.
|
|
4
|
+
related:
|
|
5
|
+
title: Related docs
|
|
6
|
+
description: Read the official Prisma PHP File Manager docs before generating or editing upload and file-management code.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/get-started-file
|
|
9
|
+
- /docs/php-validator
|
|
10
|
+
- /docs/route-php
|
|
11
|
+
- /docs/index-php
|
|
12
|
+
- /docs/pages-and-layouts
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Prisma PHP file handling should follow the documented **File Manager** model and standard PHP upload rules, not assumptions copied from Laravel storage disks, Symfony upload abstractions, Livewire temporary uploads, or custom Node-style multipart pipelines.
|
|
16
|
+
|
|
17
|
+
If a task involves file uploads, upload forms, `$_FILES`, upload size limits, allowed file types, renaming, deleting, replacing files, or building a file manager UI, AI agents should read the relevant Prisma PHP File Manager docs first and keep the implementation aligned with the installed Prisma PHP version.
|
|
18
|
+
|
|
19
|
+
## AI rule: read the File Manager docs first
|
|
20
|
+
|
|
21
|
+
Before generating, editing, or reviewing file upload or file-management code, use this order:
|
|
22
|
+
|
|
23
|
+
1. Read `./prisma-php.json`.
|
|
24
|
+
2. Read the installed local docs in `node_modules/prisma-php/dist/docs`.
|
|
25
|
+
3. Read this `file-manager.md` file.
|
|
26
|
+
4. Inspect the current route tree under `src/app`.
|
|
27
|
+
5. Inspect the current upload destination and folder structure.
|
|
28
|
+
6. Inspect Prisma PHP core internals only when the docs do not answer the task.
|
|
29
|
+
|
|
30
|
+
Do not assume another framework's storage abstraction applies directly.
|
|
31
|
+
|
|
32
|
+
## Read this doc when you need
|
|
33
|
+
|
|
34
|
+
- **basic upload form setup, `multipart/form-data`, or raw `$_FILES` behavior** → official `get-started-file`
|
|
35
|
+
- **upload validation and normalization for names or request values** → official `php-validator` plus local validation guidance in `fetching-data.md`, `error-handling.md`, and `route-handlers.md`
|
|
36
|
+
- **a rendered upload page or full-stack file manager screen** → `index.php` plus `layouts-and-pages.md`
|
|
37
|
+
- **a standalone upload endpoint, webhook-like file receiver, or direct JSON upload handler** → `route.php` plus `route-handlers.md`
|
|
38
|
+
- **local dev reload issues caused by uploaded files changing on disk** → inspect `./settings/bs-config.ts` and exclude the upload directory from BrowserSync tracking
|
|
39
|
+
|
|
40
|
+
## Core File Manager model AI should follow
|
|
41
|
+
|
|
42
|
+
The official Prisma PHP File Manager docs describe file uploads around standard PHP uploads plus a Prisma PHP helper class:
|
|
43
|
+
|
|
44
|
+
- browser upload forms must use `enctype="multipart/form-data"`
|
|
45
|
+
- uploaded file metadata is available through `$_FILES`
|
|
46
|
+
- multiple uploads use `multiple` plus a `name` ending in `[]`
|
|
47
|
+
- temporary uploads should be moved securely into the destination directory
|
|
48
|
+
- Prisma PHP provides `PP\FileManager\UploadFile` to simplify upload handling, validation, and file operations
|
|
49
|
+
|
|
50
|
+
AI should preserve that model instead of replacing it with undocumented storage helpers.
|
|
51
|
+
|
|
52
|
+
## Required upload form rules
|
|
53
|
+
|
|
54
|
+
For a normal file upload form, Prisma PHP follows standard PHP upload behavior.
|
|
55
|
+
|
|
56
|
+
A correct upload form should:
|
|
57
|
+
|
|
58
|
+
1. use `method="post"`
|
|
59
|
+
2. use `enctype="multipart/form-data"`
|
|
60
|
+
3. include a file input such as `name="file"`
|
|
61
|
+
4. use `name="files[]"` together with `multiple` for multi-file uploads
|
|
62
|
+
|
|
63
|
+
Example pattern:
|
|
64
|
+
|
|
65
|
+
```php filename="src/app/file-manager/index.php"
|
|
66
|
+
<form action="/file-manager" method="post" enctype="multipart/form-data">
|
|
67
|
+
<input type="file" name="file" />
|
|
68
|
+
<button>Upload</button>
|
|
69
|
+
</form>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Multiple upload pattern:
|
|
73
|
+
|
|
74
|
+
```php filename="src/app/file-manager/index.php"
|
|
75
|
+
<form action="/file-manager" method="post" enctype="multipart/form-data">
|
|
76
|
+
<input type="file" name="files[]" multiple="true" />
|
|
77
|
+
<button>Upload</button>
|
|
78
|
+
</form>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Understanding `$_FILES`
|
|
82
|
+
|
|
83
|
+
The File Manager docs use PHP's native `$_FILES` array as the base upload payload.
|
|
84
|
+
|
|
85
|
+
A single uploaded file typically includes values such as:
|
|
86
|
+
|
|
87
|
+
- `name`
|
|
88
|
+
- `full_path`
|
|
89
|
+
- `type`
|
|
90
|
+
- `tmp_name`
|
|
91
|
+
- `error`
|
|
92
|
+
- `size`
|
|
93
|
+
|
|
94
|
+
AI should treat `$_FILES` as the primary raw upload source before any helper class wraps it.
|
|
95
|
+
|
|
96
|
+
## Common upload error codes
|
|
97
|
+
|
|
98
|
+
The documented File Manager page highlights these common PHP upload outcomes:
|
|
99
|
+
|
|
100
|
+
| Code | Meaning |
|
|
101
|
+
| ---- | ------------------------------------------ |
|
|
102
|
+
| `0` | Success |
|
|
103
|
+
| `1` | Exceeds `upload_max_filesize` in `php.ini` |
|
|
104
|
+
| `2` | Exceeds `MAX_FILE_SIZE` in the HTML form |
|
|
105
|
+
| `3` | File partially uploaded |
|
|
106
|
+
| `4` | No file uploaded |
|
|
107
|
+
| `6` | Missing temporary folder |
|
|
108
|
+
| `7` | Failed to write to disk |
|
|
109
|
+
|
|
110
|
+
When an upload fails for one of these expected reasons, return a structured message instead of treating it like an unexplained crash.
|
|
111
|
+
|
|
112
|
+
## Size and server configuration
|
|
113
|
+
|
|
114
|
+
The official docs show two important layers of upload limits.
|
|
115
|
+
|
|
116
|
+
### HTML-side size hint
|
|
117
|
+
|
|
118
|
+
You can provide a `MAX_FILE_SIZE` hidden input before the file field.
|
|
119
|
+
|
|
120
|
+
```php
|
|
121
|
+
<input type="hidden" name="MAX_FILE_SIZE" value="51200" />
|
|
122
|
+
<input type="file" name="file" />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### PHP configuration limits
|
|
126
|
+
|
|
127
|
+
The docs call out these key `php.ini` directives:
|
|
128
|
+
|
|
129
|
+
- `file_uploads`
|
|
130
|
+
- `upload_max_filesize`
|
|
131
|
+
- `post_max_size`
|
|
132
|
+
- `max_file_uploads`
|
|
133
|
+
|
|
134
|
+
AI should remember that HTML limits do not replace server limits. If upload behavior is failing, inspect `php.ini` constraints as part of the diagnosis.
|
|
135
|
+
|
|
136
|
+
## Secure destination handling
|
|
137
|
+
|
|
138
|
+
Uploaded files first land in temporary storage and must then be moved into the intended destination.
|
|
139
|
+
|
|
140
|
+
The base PHP pattern is:
|
|
141
|
+
|
|
142
|
+
```php
|
|
143
|
+
move_uploaded_file(
|
|
144
|
+
$_FILES['file']['tmp_name'],
|
|
145
|
+
DOCUMENT_PATH . '/uploads/' . $_FILES['file']['name']
|
|
146
|
+
);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Do not leave files in temporary storage or assume the browser upload itself completed the final save.
|
|
150
|
+
|
|
151
|
+
## The `UploadFile` class
|
|
152
|
+
|
|
153
|
+
The Prisma PHP File Manager docs describe a dedicated helper class for uploads:
|
|
154
|
+
|
|
155
|
+
```php
|
|
156
|
+
use PP\FileManager\UploadFile;
|
|
157
|
+
|
|
158
|
+
$upload = new UploadFile(DOCUMENT_PATH . '/uploads/');
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This class is the documented Prisma PHP abstraction AI should prefer when the task is specifically about file uploads and management.
|
|
162
|
+
|
|
163
|
+
## Exact core file location
|
|
164
|
+
|
|
165
|
+
The Prisma PHP core `UploadFile` class lives here:
|
|
166
|
+
|
|
167
|
+
```txt
|
|
168
|
+
vendor/tsnc/prisma-php/src/FileManager/UploadFile.php
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
When AI needs to inspect framework internals because the docs do not fully answer a File Manager task, this is the exact core file to review.
|
|
172
|
+
|
|
173
|
+
## Documented `UploadFile` capabilities
|
|
174
|
+
|
|
175
|
+
The official docs describe these responsibilities for `UploadFile`:
|
|
176
|
+
|
|
177
|
+
- built-in size validation
|
|
178
|
+
- secure type restriction
|
|
179
|
+
- filename cleanup and sanitization
|
|
180
|
+
- automatic handling of multiple uploads
|
|
181
|
+
|
|
182
|
+
This makes `UploadFile` the preferred documented tool for ordinary file-manager flows rather than manually reimplementing every upload rule.
|
|
183
|
+
|
|
184
|
+
## Public methods AI should know
|
|
185
|
+
|
|
186
|
+
The File Manager docs list these public methods:
|
|
187
|
+
|
|
188
|
+
- `upload(bool $renameDuplicates = true): void`
|
|
189
|
+
- `update(array $file, string $oldFilename): bool`
|
|
190
|
+
- `setMaxSize(int $bytes): void`
|
|
191
|
+
- `setPermittedTypes(array $mimeTypes): void`
|
|
192
|
+
- `allowAllTypes(?string $suffix = null): void`
|
|
193
|
+
- `rename(string $oldName, string $newName): bool`
|
|
194
|
+
- `delete(string $filename): bool`
|
|
195
|
+
- `getMessages(): array`
|
|
196
|
+
- `getErrorCode(): array`
|
|
197
|
+
- `getSuccessfulUploads(): array`
|
|
198
|
+
- `static convertToBytes(string $val): int`
|
|
199
|
+
- `static convertFromBytes(int $bytes): string`
|
|
200
|
+
|
|
201
|
+
AI should not invent undocumented methods when these already cover the common workflow.
|
|
202
|
+
|
|
203
|
+
## Validation boundary
|
|
204
|
+
|
|
205
|
+
For file manager pages and upload-related actions, keep these concerns separate:
|
|
206
|
+
|
|
207
|
+
- use **`UploadFile`** for upload operations and file handling
|
|
208
|
+
- use **`PP\Validator`** for validating user-provided values such as rename targets, labels, or other request fields
|
|
209
|
+
- use structured return values for expected validation failures
|
|
210
|
+
- use route pages or route handlers according to the documented `index.php` versus `route.php` split
|
|
211
|
+
|
|
212
|
+
Do not use filename cleanup as a substitute for validating other request data.
|
|
213
|
+
|
|
214
|
+
## Organization guidance
|
|
215
|
+
|
|
216
|
+
The official docs include a practical storage rule:
|
|
217
|
+
|
|
218
|
+
- keep uploaded files outside `src/app`, because `src/app` is route and application logic
|
|
219
|
+
- use a destination like `/uploads` at the root or `src/uploads` when that matches the project structure
|
|
220
|
+
|
|
221
|
+
AI should avoid placing user-uploaded files inside the route tree.
|
|
222
|
+
|
|
223
|
+
## Local development reload rule
|
|
224
|
+
|
|
225
|
+
When uploaded files are saved into a watched local directory, BrowserSync or the local dev server may reload on every file change. For File Manager workflows, that can create noisy refresh loops during upload, rename, replace, or delete actions.
|
|
226
|
+
|
|
227
|
+
To avoid tracking file storage changes during local development, exclude the upload directory in:
|
|
228
|
+
|
|
229
|
+
```txt
|
|
230
|
+
./settings/bs-config.ts
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Prisma PHP projects can use:
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const PUBLIC_IGNORE_DIRS = [""];
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
For local file uploads, add the upload directory path there so BrowserSync ignores storage mutations.
|
|
240
|
+
|
|
241
|
+
Example pattern:
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
const PUBLIC_IGNORE_DIRS = ["uploads"];
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
If the project stores files in another public directory, exclude that directory instead. AI should not leave upload directories watched when the local server reload behavior becomes disruptive.
|
|
248
|
+
|
|
249
|
+
## Full-stack file manager pattern
|
|
250
|
+
|
|
251
|
+
The official File Manager example shows a normal Prisma PHP page route such as:
|
|
252
|
+
|
|
253
|
+
```txt
|
|
254
|
+
src/app/file-manager/index.php
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The example combines these building blocks in one route:
|
|
258
|
+
|
|
259
|
+
- `PP\FileManager\UploadFile`
|
|
260
|
+
- `PP\Validator`
|
|
261
|
+
- `PP\StateManager`
|
|
262
|
+
- a standard multipart upload form
|
|
263
|
+
- upload status messages
|
|
264
|
+
- file listing
|
|
265
|
+
- rename action
|
|
266
|
+
- delete action
|
|
267
|
+
|
|
268
|
+
That means a normal File Manager screen in Prisma PHP can be built as a full-stack route page without inventing a separate frontend framework.
|
|
269
|
+
|
|
270
|
+
## Recommended AI workflow for file-manager tasks
|
|
271
|
+
|
|
272
|
+
When the user asks for upload or file-manager functionality, AI should usually follow this order:
|
|
273
|
+
|
|
274
|
+
1. read `prisma-php.json`
|
|
275
|
+
2. read the official File Manager docs
|
|
276
|
+
3. decide whether the task is a rendered page (`index.php`) or a direct handler (`route.php`)
|
|
277
|
+
4. choose the upload destination directory
|
|
278
|
+
5. if local reload becomes noisy, exclude the upload directory in `./settings/bs-config.ts`
|
|
279
|
+
6. use `UploadFile` for upload, rename, update, and delete operations when it fits the documented workflow
|
|
280
|
+
7. use `PP\Validator` for rename fields or other non-file request values
|
|
281
|
+
8. return structured messages for expected failures
|
|
282
|
+
9. inspect Prisma PHP internals only if the docs and local project usage are not enough
|
|
283
|
+
|
|
284
|
+
## AI rules for file uploads and file management
|
|
285
|
+
|
|
286
|
+
- read the official File Manager docs before generating upload code
|
|
287
|
+
- do not guess file-upload behavior from Laravel Storage, Symfony UploadedFile, Livewire, or Node middleware
|
|
288
|
+
- do not omit `enctype="multipart/form-data"` on upload forms
|
|
289
|
+
- do not forget the `[]` suffix when generating multiple-file inputs
|
|
290
|
+
- do not assume HTML size hints replace `php.ini` limits
|
|
291
|
+
- do not write uploaded files into `src/app`
|
|
292
|
+
- do not trust browser-only checks as the final validation layer
|
|
293
|
+
- do not invent undocumented File Manager helper methods
|
|
294
|
+
- use `UploadFile` when the task matches the documented Prisma PHP upload workflow
|
|
295
|
+
- use `PP\Validator` for auxiliary request validation such as rename input validation
|
|
296
|
+
- remember that the core `UploadFile` implementation lives in `vendor/tsnc/prisma-php/src/FileManager/UploadFile.php`
|
|
297
|
+
- when local uploads cause dev-server refresh noise, exclude the upload directory from BrowserSync tracking in `./settings/bs-config.ts`
|
|
298
|
+
|
|
299
|
+
## Suggested file name
|
|
300
|
+
|
|
301
|
+
Use this file name:
|
|
302
|
+
|
|
303
|
+
```txt
|
|
304
|
+
file-manager.md
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
It is clear, consistent with the existing local docs set, and easy for AI agents to discover alongside files such as `authentication.md`, `components.md`, and `route-handlers.md`.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Prisma PHP Docs
|
|
3
|
+
description: Welcome to the Prisma PHP Documentation.
|
|
4
|
+
related:
|
|
5
|
+
title: Next Steps
|
|
6
|
+
description: Create your first Prisma PHP application and learn the core framework features.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/get-started
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
{/_ AI agent hint: Prisma PHP uses local installed docs as the source of truth for the active project version. Before generating framework-specific code, read `prisma-php.json` first, then read the relevant docs from `node_modules/prisma-php/dist/docs`. For authentication, read `authentication.md` first, then verify the official auth docs: `auth-get-started`, `credentials`, and `state-manager-auth`. For file uploads, `multipart/form-data`, `$_FILES`, `PP\FileManager\UploadFile`, rename/delete flows, or file manager screens, read `file-manager.md` first, then verify the official File Manager docs: `get-started-file`. For ORM work, read `prisma-php-orm.md` before choosing schema, migration, or generation commands. For PulsePoint runtime behavior specifically, read `pulsepoint.md` before generating reactive UI code. For backend validation, sanitization, `Validator`, `Rule`, `pp.fetchFunction(...)` validation flows, or request validation in `route.php`, read `fetching-data.md`, `error-handling.md`, and `route-handlers.md`, then consult the official Validator docs. `PP\Validator` is a Prisma PHP core class located in `vendor/tsnc/prisma-php/src/Validator.php`. Route creation is file-based from `src/app`; Prisma PHP auto-generates route listings such as `files-list.json`, so AI agents must not create, edit, or maintain that file manually. _/}
|
|
12
|
+
|
|
13
|
+
Welcome to the Prisma PHP documentation!
|
|
14
|
+
|
|
15
|
+
## What is Prisma PHP?
|
|
16
|
+
|
|
17
|
+
Prisma PHP is a full-stack PHP framework for building modern, reactive web applications.
|
|
18
|
+
|
|
19
|
+
You use native PHP to build your application, Prisma ORM for type-safe data access, and PulsePoint to add reactive browser state without the usual API glue or hydration-heavy workflow.
|
|
20
|
+
|
|
21
|
+
It is designed to give you a server-first development model with modern UI interactivity, reusable PHPX components, Next.js-style routing concepts adapted for Prisma PHP, and CLI tooling.
|
|
22
|
+
|
|
23
|
+
Whether you're building an internal dashboard, a content-rich platform, or a custom product, Prisma PHP helps you move fast while keeping your stack cohesive and expressive.
|
|
24
|
+
|
|
25
|
+
## AI quick start
|
|
26
|
+
|
|
27
|
+
If you are using AI-assisted development, do not guess framework behavior from other ecosystems.
|
|
28
|
+
|
|
29
|
+
Use this order:
|
|
30
|
+
|
|
31
|
+
1. Read `./prisma-php.json` first.
|
|
32
|
+
2. Read the relevant local docs in `node_modules/prisma-php/dist/docs`.
|
|
33
|
+
3. Inspect local project files.
|
|
34
|
+
4. Inspect `vendor/tsnc/prisma-php/src` only when framework internals are necessary.
|
|
35
|
+
|
|
36
|
+
### Read this doc when you need
|
|
37
|
+
|
|
38
|
+
- **project setup or file placement** → `project-structure.md`
|
|
39
|
+
- **pages, layouts, route creation, nested routes** → `layouts-and-pages.md`
|
|
40
|
+
- **PHPX components, props, children, fragments, icons, buttons, accordions, or component composition** → `components.md`
|
|
41
|
+
- **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`
|
|
42
|
+
- **authentication strategy, `AuthConfig.php`, sign-in, sign-out, route privacy model, RBAC, credentials auth, social login, or auth state manager usage** → `authentication.md`
|
|
43
|
+
- **`pp.fetchFunction(...)`, `#[Exposed]`, page data loading, interactive validation with `Validator`** → `fetching-data.md`
|
|
44
|
+
- **cache behavior and `CacheHandler`** → `caching.md`
|
|
45
|
+
- **ORM, `schema.prisma`, database provider, migrations, generated PHP classes, `prisma.config.ts`, `.env` `DATABASE_URL`, or Prisma CLI workflow** → `prisma-php-orm.md`
|
|
46
|
+
- **error handling, `error.php`, `not-found.php`, expected validation errors** → `error-handling.md`
|
|
47
|
+
- **metadata, title, description, favicon, icons** → `metadata-and-og-images.md`
|
|
48
|
+
- **API-style endpoints, `route.php`, request validation with `Validator`** → `route-handlers.md`
|
|
49
|
+
- **PulsePoint runtime APIs such as `pp.state`, `pp.effect`, `pp.ref`, `pp-for`, `pp-ref`, `pp-spread`** → `pulsepoint.md`
|
|
50
|
+
- **updating the project or enabling features** → `upgrading.md`
|
|
51
|
+
- **first-time project creation** → `installation.md`
|
|
52
|
+
|
|
53
|
+
### Important AI rules
|
|
54
|
+
|
|
55
|
+
- treat `node_modules/prisma-php/dist/docs` as the primary documentation source for the installed version
|
|
56
|
+
- do not assume Laravel, Symfony, React, Vue, Alpine, Livewire, or Next.js behavior maps directly
|
|
57
|
+
- do not guess routing, file conventions, request helpers, component APIs, reactive syntax, or auth behavior when local docs already define them
|
|
58
|
+
- create routes by adding folders and route files under `src/app`
|
|
59
|
+
- do not create, edit, or maintain `files-list.json`; Prisma PHP generates route listings automatically
|
|
60
|
+
- when building interactive frontend behavior, prefer the documented PulsePoint pattern with browser-side reactive state and `pp.fetchFunction(...)` for server calls
|
|
61
|
+
- when using `pp.fetchFunction(...)`, expose the PHP function explicitly with `#[Exposed]`
|
|
62
|
+
- when changing feature flags, update `prisma-php.json` first, then follow the documented update workflow
|
|
63
|
+
- when building reusable PHPX components, read `components.md` first
|
|
64
|
+
- 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
|
|
65
|
+
- when building auth flows, protection rules, or login/register pages, read `authentication.md` first and keep the implementation aligned with Prisma PHP’s documented auth model
|
|
66
|
+
|
|
67
|
+
## File Manager
|
|
68
|
+
|
|
69
|
+
Prisma PHP includes a documented File Manager model for uploads and file operations based on standard PHP uploads plus `PP\FileManager\UploadFile`.
|
|
70
|
+
|
|
71
|
+
Use `file-manager.md` as the local AI-awareness guide for:
|
|
72
|
+
|
|
73
|
+
- upload forms with `multipart/form-data`
|
|
74
|
+
- `$_FILES` handling
|
|
75
|
+
- `PP\FileManager\UploadFile`
|
|
76
|
+
- upload size and type restrictions
|
|
77
|
+
- rename, replace, and delete flows
|
|
78
|
+
- choosing between a rendered upload page and a direct upload handler
|
|
79
|
+
- validating non-file request values with `PP\Validator`
|
|
80
|
+
|
|
81
|
+
After reading `file-manager.md`, verify the matching official docs at:
|
|
82
|
+
|
|
83
|
+
1. `get-started-file`
|
|
84
|
+
2. `php-validator` when auxiliary request validation is needed
|
|
85
|
+
3. `route-php` or `pages-and-layouts` depending on whether the task is a direct handler or a full-stack page
|
|
86
|
+
|
|
87
|
+
## Authentication
|
|
88
|
+
|
|
89
|
+
Prisma PHP includes a documented authentication model centered on sessions, route protection strategy, RBAC, and provider-based sign-in flows.
|
|
90
|
+
|
|
91
|
+
Use `authentication.md` as the local AI-awareness guide for:
|
|
92
|
+
|
|
93
|
+
- `AuthConfig.php`
|
|
94
|
+
- public-default vs private-default route strategy
|
|
95
|
+
- `Auth::signIn(...)`
|
|
96
|
+
- `Auth::signOut(...)`
|
|
97
|
+
- `refreshUserSession(...)`
|
|
98
|
+
- route-level RBAC
|
|
99
|
+
- function-level protection with `#[Exposed(allowedRoles: [...])]`
|
|
100
|
+
- credential authentication
|
|
101
|
+
- social authentication
|
|
102
|
+
|
|
103
|
+
After reading `authentication.md`, verify the matching official docs in this order:
|
|
104
|
+
|
|
105
|
+
1. `auth-get-started`
|
|
106
|
+
2. `credentials`
|
|
107
|
+
3. `state-manager-auth`
|
|
108
|
+
|
|
109
|
+
## Routing and file conventions
|
|
110
|
+
|
|
111
|
+
Prisma PHP uses file-based routing.
|
|
112
|
+
|
|
113
|
+
Important files include:
|
|
114
|
+
|
|
115
|
+
- `index.php`
|
|
116
|
+
- `layout.php`
|
|
117
|
+
- `loading.php`
|
|
118
|
+
- `route.php`
|
|
119
|
+
- `not-found.php`
|
|
120
|
+
- `error.php`
|
|
121
|
+
- metadata files and icons
|
|
122
|
+
|
|
123
|
+
Routes are created from the `src/app` folder structure and route files. AI agents should not try to register routes manually in framework-generated route list files.
|
|
124
|
+
|
|
125
|
+
If you are changing route behavior or navigation patterns, read the routing documentation first.
|
|
126
|
+
|
|
127
|
+
## Data and reactivity
|
|
128
|
+
|
|
129
|
+
One of Prisma PHP’s core ideas is keeping data flow simple across the stack:
|
|
130
|
+
|
|
131
|
+
- Query data with Prisma ORM in PHP
|
|
132
|
+
- Render full-stack UI directly from route files
|
|
133
|
+
- Use PulsePoint for frontend reactivity
|
|
134
|
+
- Use `pp.fetchFunction(...)` for reactive frontend-to-server calls
|
|
135
|
+
- Expose callable PHP functions with `#[Exposed]`
|
|
136
|
+
- Validate incoming request data with `PP\Validator`
|
|
137
|
+
|
|
138
|
+
This makes it easier to build interactive applications without maintaining separate DTO layers, excessive transformation code, or client-heavy hydration logic.
|
|
139
|
+
|
|
140
|
+
When Prisma ORM data is loaded in `index.php`, treat normal query results as the model-shaped objects returned by the generated Prisma PHP classes that follow `prisma/schema.prisma`.
|
|
141
|
+
|
|
142
|
+
Do not introduce defensive serializer layers by default just to make normal ORM results usable. Use `PP\Validator` for incoming payload validation, sanitization, casting, and rule-based checks. Only add a presentation mapper when you intentionally need a client-facing shape, such as flattening included relations, hiding sensitive fields, or formatting values for display.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation
|
|
3
|
+
description: Learn how to create a new Prisma PHP application with the `create-prisma-php-app` CLI and start building locally.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Create a new Prisma PHP app and run it locally.
|
|
7
|
+
|
|
8
|
+
## Quick start
|
|
9
|
+
|
|
10
|
+
1. Create a new Prisma PHP app.
|
|
11
|
+
2. Change into the project directory.
|
|
12
|
+
3. Start the local development environment.
|
|
13
|
+
|
|
14
|
+
```bash package="npm"
|
|
15
|
+
npx create-prisma-php-app@latest
|
|
16
|
+
cd my-app
|
|
17
|
+
npm run dev
|
|
18
|
+
```
|