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,289 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Layouts and Pages
|
|
3
|
+
description: Learn how to create your first pages and layouts in Prisma PHP, and structure routes using the framework's file conventions.
|
|
4
|
+
related:
|
|
5
|
+
title: API Reference
|
|
6
|
+
description: Learn more about the features mentioned in this page by reading the Prisma PHP routing documentation.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/pages-and-layouts
|
|
9
|
+
- /docs/defining-routes
|
|
10
|
+
- /docs/route-groups
|
|
11
|
+
- /docs/private-folders
|
|
12
|
+
- /docs/dynamic-route
|
|
13
|
+
- /docs/index-php
|
|
14
|
+
- /docs/route-php
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
Prisma PHP uses **file-system based routing**, meaning you can use folders and files to define routes. This page will guide you through how to create layouts and pages, and organize them using Prisma PHP conventions.
|
|
18
|
+
|
|
19
|
+
## Important route generation note
|
|
20
|
+
|
|
21
|
+
In Prisma PHP, routes are created from folders and special files inside `src/app`.
|
|
22
|
+
|
|
23
|
+
Do **not** create or maintain routes by editing `files-list.json`. Prisma PHP generates that file automatically.
|
|
24
|
+
|
|
25
|
+
When adding a page or nested route, create the correct folder and add the proper file such as `index.php`, `layout.php`, or `route.php`, then let the framework regenerate route metadata.
|
|
26
|
+
|
|
27
|
+
## Choosing `index.php` vs `route.php`
|
|
28
|
+
|
|
29
|
+
Prisma PHP has two important route entry files, and they serve different purposes.
|
|
30
|
+
|
|
31
|
+
- `index.php` is the **UI entry point** for a route. Use it when the route should render HTML or a normal full-stack page.
|
|
32
|
+
- `route.php` is the **direct handler entry point** for a route. Use it when the route should behave like an API endpoint, JSON endpoint, AJAX handler, form-processing endpoint, or other no-view server handler.
|
|
33
|
+
|
|
34
|
+
A helpful project-level rule comes from `prisma-php.json`:
|
|
35
|
+
|
|
36
|
+
- when `backendOnly` is `false`, the project is full-stack, so normal routes should usually be built with `index.php`
|
|
37
|
+
- when `backendOnly` is `true`, the project is backend-only, so route behavior will usually center on `route.php`
|
|
38
|
+
|
|
39
|
+
For the example project configuration below, `backendOnly` is `false`, so the default route choice for normal app routes is `index.php`.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"backendOnly": false
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the user asks for a **route or page**, prefer `index.php`. If the user asks for an **API route**, direct handler, JSON endpoint, webhook, or AJAX route, prefer `route.php`.
|
|
48
|
+
|
|
49
|
+
## Creating a page
|
|
50
|
+
|
|
51
|
+
A **page** is UI that is rendered on a specific route. In Prisma PHP, you define a page by creating an `index.php` file inside a route folder. The page becomes publicly accessible based on its folder path.
|
|
52
|
+
|
|
53
|
+
For example, to create an index page (`/`):
|
|
54
|
+
|
|
55
|
+
```php filename="src/app/index.php"
|
|
56
|
+
<?php
|
|
57
|
+
|
|
58
|
+
echo "<h1>Hello Prisma PHP!</h1>";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A route is created from the folder structure, and `index.php` is the default file used for route UI.
|
|
62
|
+
|
|
63
|
+
## Creating a layout
|
|
64
|
+
|
|
65
|
+
A layout is UI that is **shared** between multiple pages. Layouts wrap all child pages of the corresponding route and are useful for persistent application structure such as headers, sidebars, navigation, and footers.
|
|
66
|
+
|
|
67
|
+
You can define a layout by creating a `layout.php` file. The root layout is required and applies to all routes.
|
|
68
|
+
|
|
69
|
+
For example, to create a root layout:
|
|
70
|
+
|
|
71
|
+
```php filename="src/app/layout.php"
|
|
72
|
+
|
|
73
|
+
<?php use PP\MainLayout; ?>
|
|
74
|
+
|
|
75
|
+
<!DOCTYPE html>
|
|
76
|
+
<html lang="en">
|
|
77
|
+
<head>
|
|
78
|
+
<meta charset="UTF-8">
|
|
79
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
80
|
+
<title>My Prisma PHP App</title>
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<main>
|
|
84
|
+
<?= MainLayout::$children; ?>
|
|
85
|
+
</main>
|
|
86
|
+
</body>
|
|
87
|
+
</html>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The root layout is defined at the top level of your app directory and wraps the content for the entire application.
|
|
91
|
+
|
|
92
|
+
## Creating a nested route
|
|
93
|
+
|
|
94
|
+
A nested route is a route composed of multiple URL segments. In Prisma PHP, folders define route segments and files such as `index.php` and `layout.php` define the UI shown for each segment.
|
|
95
|
+
|
|
96
|
+
To create a nested route, nest folders inside the app directory. For example, to add a route for `/blog`, create a `blog` folder and add an `index.php` file:
|
|
97
|
+
|
|
98
|
+
```txt
|
|
99
|
+
src/app/
|
|
100
|
+
├── index.php → /
|
|
101
|
+
└── blog/
|
|
102
|
+
└── index.php → /blog
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```php filename="src/app/blog/index.php"
|
|
106
|
+
<?php
|
|
107
|
+
|
|
108
|
+
echo "<h1>Blog</h1>";
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You can continue nesting folders to create deeper routes. For example, to create a route for a specific blog post:
|
|
112
|
+
|
|
113
|
+
```txt
|
|
114
|
+
src/app/
|
|
115
|
+
└── blog/
|
|
116
|
+
└── [slug]/
|
|
117
|
+
└── index.php → /blog/my-first-post
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```php filename="src/app/blog/[slug]/index.php"
|
|
121
|
+
<?php
|
|
122
|
+
|
|
123
|
+
use PP\Request;
|
|
124
|
+
|
|
125
|
+
$slug = Request::$dynamicParams['slug'] ?? null;
|
|
126
|
+
|
|
127
|
+
echo "<h1>Blog post: " . htmlspecialchars((string) $slug) . "</h1>";
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Wrapping a folder name in square brackets creates a **dynamic route segment** that can be filled from the incoming URL.
|
|
131
|
+
|
|
132
|
+
## Nesting layouts
|
|
133
|
+
|
|
134
|
+
Layouts are also nested by default. When you place a `layout.php` file inside a route folder, that layout wraps the pages and nested routes under that segment.
|
|
135
|
+
|
|
136
|
+
For example, to create a layout for the `/blog` route:
|
|
137
|
+
|
|
138
|
+
```txt
|
|
139
|
+
src/app/
|
|
140
|
+
├── layout.php → root layout
|
|
141
|
+
└── blog/
|
|
142
|
+
├── layout.php → blog layout
|
|
143
|
+
├── index.php → /blog
|
|
144
|
+
└── [slug]/
|
|
145
|
+
└── index.php → /blog/my-first-post
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```php filename="src/app/blog/layout.php"
|
|
149
|
+
|
|
150
|
+
<?php use PP\MainLayout; ?>
|
|
151
|
+
|
|
152
|
+
<section>
|
|
153
|
+
<header>
|
|
154
|
+
<h1>Blog Section</h1>
|
|
155
|
+
</header>
|
|
156
|
+
|
|
157
|
+
<?= MainLayout::$children; ?>
|
|
158
|
+
</section>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If you combine both layouts, the root layout wraps the blog layout, and the blog layout wraps both `src/app/blog/index.php` and `src/app/blog/[slug]/index.php`.
|
|
162
|
+
|
|
163
|
+
## Creating a dynamic segment
|
|
164
|
+
|
|
165
|
+
Dynamic segments allow you to generate routes from data when you do not know the exact segment names ahead of time.
|
|
166
|
+
|
|
167
|
+
To create a dynamic segment, wrap the folder name in square brackets: `[segmentName]`.
|
|
168
|
+
|
|
169
|
+
For example:
|
|
170
|
+
|
|
171
|
+
```txt
|
|
172
|
+
src/app/
|
|
173
|
+
└── blog/
|
|
174
|
+
└── [slug]/
|
|
175
|
+
└── index.php
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Dynamic parameters are available through `Request::$dynamicParams` in `layout.php`, `index.php`, and `route.php`.
|
|
179
|
+
|
|
180
|
+
```php filename="src/app/blog/[slug]/index.php"
|
|
181
|
+
<?php
|
|
182
|
+
|
|
183
|
+
use PP\Request;
|
|
184
|
+
|
|
185
|
+
$params = Request::$dynamicParams;
|
|
186
|
+
$slug = $params['slug'] ?? '';
|
|
187
|
+
|
|
188
|
+
echo "<article>";
|
|
189
|
+
echo "<h1>Post: " . htmlspecialchars((string) $slug) . "</h1>";
|
|
190
|
+
echo "</article>";
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Multiple route parameters
|
|
194
|
+
|
|
195
|
+
Prisma PHP also supports catch-all style dynamic segments using `[...routename]`.
|
|
196
|
+
|
|
197
|
+
```txt
|
|
198
|
+
src/app/
|
|
199
|
+
└── docs/
|
|
200
|
+
└── [...slug]/
|
|
201
|
+
└── index.php
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```php filename="src/app/docs/[...slug]/index.php"
|
|
205
|
+
<?php
|
|
206
|
+
|
|
207
|
+
use PP\Request;
|
|
208
|
+
|
|
209
|
+
$parts = Request::$dynamicParams['slug'] ?? [];
|
|
210
|
+
|
|
211
|
+
echo json_encode($parts);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Using route groups with layouts
|
|
215
|
+
|
|
216
|
+
Route groups let you organize routes without affecting the URL path. A route group is created by wrapping a folder name in parentheses.
|
|
217
|
+
|
|
218
|
+
```txt
|
|
219
|
+
src/app/
|
|
220
|
+
├── layout.php
|
|
221
|
+
├── (marketing)/
|
|
222
|
+
│ ├── layout.php
|
|
223
|
+
│ ├── about/
|
|
224
|
+
│ │ └── index.php → /about
|
|
225
|
+
│ └── blog/
|
|
226
|
+
│ └── index.php → /blog
|
|
227
|
+
└── (dashboard)/
|
|
228
|
+
├── layout.php
|
|
229
|
+
└── account/
|
|
230
|
+
└── index.php → /account
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Even though `(marketing)` and `(dashboard)` are part of the folder structure, they are omitted from the URL. This makes them useful for assigning different layouts to different sections of the app without changing route paths.
|
|
234
|
+
|
|
235
|
+
## Private folders
|
|
236
|
+
|
|
237
|
+
Private folders can be created by prefixing a folder name with an underscore, such as `_components` or `_lib`.
|
|
238
|
+
|
|
239
|
+
These folders are treated as private implementation details and are opted out of routing.
|
|
240
|
+
|
|
241
|
+
```txt
|
|
242
|
+
src/app/
|
|
243
|
+
└── blog/
|
|
244
|
+
├── index.php → /blog
|
|
245
|
+
├── _components/
|
|
246
|
+
│ └── post-card.php
|
|
247
|
+
└── _lib/
|
|
248
|
+
└── posts.php
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Private folders are useful for colocating view helpers, partials, utility files, and internal logic next to the route that uses them.
|
|
252
|
+
|
|
253
|
+
## When to use `route.php` instead
|
|
254
|
+
|
|
255
|
+
Even in a full-stack Prisma PHP application, there are times when `route.php` is the right tool.
|
|
256
|
+
|
|
257
|
+
Use `route.php` when you need:
|
|
258
|
+
|
|
259
|
+
- JSON API endpoints
|
|
260
|
+
- AJAX handlers
|
|
261
|
+
- webhook receivers
|
|
262
|
+
- form-processing endpoints without page rendering
|
|
263
|
+
- direct logic routes that should bypass standard view rendering
|
|
264
|
+
|
|
265
|
+
Example:
|
|
266
|
+
|
|
267
|
+
```php filename="src/app/users/route.php"
|
|
268
|
+
<?php
|
|
269
|
+
|
|
270
|
+
echo json_encode([
|
|
271
|
+
'success' => true,
|
|
272
|
+
]);
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Good to know
|
|
276
|
+
|
|
277
|
+
- Prisma PHP uses file-system routing where folders map to URL segments.
|
|
278
|
+
- `index.php` is the normal route UI entry point.
|
|
279
|
+
- `route.php` is the direct handler entry point.
|
|
280
|
+
- In full-stack projects, normal routes should usually use `index.php`.
|
|
281
|
+
- In backend-only projects, route behavior usually centers on `route.php`.
|
|
282
|
+
- If a user asks for a normal route or page, prefer `index.php`.
|
|
283
|
+
- If a user asks for an API route or direct handler, prefer `route.php`.
|
|
284
|
+
- The root layout is required and should contain the global HTML document structure.
|
|
285
|
+
- Only the root layout should contain `<html>` and `<body>` tags.
|
|
286
|
+
- Layouts can be nested by placing `layout.php` files inside route folders.
|
|
287
|
+
- Dynamic route parameters are available through `Request::$dynamicParams`.
|
|
288
|
+
- Route groups let you organize routes and assign different layouts without affecting the URL.
|
|
289
|
+
- Private folders help you colocate implementation files without making them routable.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Metadata and Icons
|
|
3
|
+
description: Learn how to manage page metadata and application icons in Prisma PHP.
|
|
4
|
+
related:
|
|
5
|
+
title: API Reference
|
|
6
|
+
description: Learn more about metadata and icon file conventions in Prisma PHP.
|
|
7
|
+
links:
|
|
8
|
+
- /docs/metadata
|
|
9
|
+
- /docs/metadata-icons
|
|
10
|
+
- /docs/layout.php
|
|
11
|
+
- /docs/pages-and-layouts
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
This page explains how to manage metadata in Prisma PHP and how icon file conventions such as `favicon`, `icon`, and `apple-icon` work.
|
|
15
|
+
|
|
16
|
+
Prisma PHP’s metadata system is centered on the `MainLayout` class rather than Next.js exports like `metadata`, `generateMetadata`, or generated `opengraph-image.tsx`. The provided Prisma PHP docs describe dynamic page metadata and icon file conventions, but they do **not** document a dedicated Next.js-style generated Open Graph image pipeline on these pages. citeturn0view0turn1view0
|
|
17
|
+
|
|
18
|
+
## Metadata in Prisma PHP
|
|
19
|
+
|
|
20
|
+
Prisma PHP lets you update metadata dynamically through the `MainLayout` class.
|
|
21
|
+
|
|
22
|
+
The docs say this is used to manage head scripts, footer scripts, and custom metadata for each page. citeturn0view0
|
|
23
|
+
|
|
24
|
+
### Basic metadata example
|
|
25
|
+
|
|
26
|
+
```php filename="src/app/products/index.php"
|
|
27
|
+
<?php
|
|
28
|
+
|
|
29
|
+
use Lib\MainLayout;
|
|
30
|
+
|
|
31
|
+
MainLayout::$title = "My Awesome Page";
|
|
32
|
+
MainLayout::$description = "This is a description of my awesome page";
|
|
33
|
+
MainLayout::addCustomMetaData("author", "John Doe");
|
|
34
|
+
?>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
In this model:
|
|
38
|
+
|
|
39
|
+
- `MainLayout::$title` sets the page title
|
|
40
|
+
- `MainLayout::$description` sets the page description
|
|
41
|
+
- `MainLayout::addCustomMetaData(...)` adds additional metadata such as `author` or other `<meta>` values citeturn0view0
|
|
42
|
+
|
|
43
|
+
## Dynamic metadata
|
|
44
|
+
|
|
45
|
+
Prisma PHP also supports dynamic metadata based on request data or other runtime conditions.
|
|
46
|
+
|
|
47
|
+
The docs show metadata being generated from request parameters:
|
|
48
|
+
|
|
49
|
+
```php filename="src/app/product/index.php"
|
|
50
|
+
<?php
|
|
51
|
+
|
|
52
|
+
use Lib\MainLayout;
|
|
53
|
+
use Lib\Request;
|
|
54
|
+
|
|
55
|
+
$productName = Request::$params->productName ?? '';
|
|
56
|
+
$productDescription = Request::$params->productDescription ?? '';
|
|
57
|
+
|
|
58
|
+
MainLayout::$title = "Product: " . $productName;
|
|
59
|
+
MainLayout::$description = $productDescription;
|
|
60
|
+
?>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This is the closest Prisma PHP equivalent to route-aware or dynamic metadata generation. citeturn0view0
|
|
64
|
+
|
|
65
|
+
## Important placement rule
|
|
66
|
+
|
|
67
|
+
The Prisma PHP docs explicitly note that metadata should be set **at the top of the PHP file before any HTML output** so it can render correctly inside the document `<head>`. citeturn0view0
|
|
68
|
+
|
|
69
|
+
That means this pattern is correct:
|
|
70
|
+
|
|
71
|
+
```php filename="src/app/about/index.php"
|
|
72
|
+
<?php
|
|
73
|
+
|
|
74
|
+
use Lib\MainLayout;
|
|
75
|
+
|
|
76
|
+
MainLayout::$title = "About Us";
|
|
77
|
+
MainLayout::$description = "Learn more about our company.";
|
|
78
|
+
|
|
79
|
+
?>
|
|
80
|
+
|
|
81
|
+
<section>
|
|
82
|
+
<h1>About Us</h1>
|
|
83
|
+
</section>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Adding custom metadata
|
|
87
|
+
|
|
88
|
+
You can attach additional custom metadata through `MainLayout::addCustomMetaData(...)`.
|
|
89
|
+
|
|
90
|
+
```php filename="src/app/blog/index.php"
|
|
91
|
+
<?php
|
|
92
|
+
|
|
93
|
+
use Lib\MainLayout;
|
|
94
|
+
|
|
95
|
+
MainLayout::$title = "Blog";
|
|
96
|
+
MainLayout::$description = "Latest articles and product updates.";
|
|
97
|
+
MainLayout::addCustomMetaData("keywords", "blog, updates, articles");
|
|
98
|
+
MainLayout::addCustomMetaData("author", "Prisma PHP Team");
|
|
99
|
+
?>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This is useful for:
|
|
103
|
+
|
|
104
|
+
- `author`
|
|
105
|
+
- `keywords`
|
|
106
|
+
- custom SEO tags
|
|
107
|
+
- social or app-specific metadata values
|
|
108
|
+
|
|
109
|
+
## Adding scripts to the head and footer
|
|
110
|
+
|
|
111
|
+
The docs also describe metadata-related layout hooks for scripts.
|
|
112
|
+
|
|
113
|
+
You can inject scripts into the document head or footer with:
|
|
114
|
+
|
|
115
|
+
- `MainLayout::addHeadScript(...)`
|
|
116
|
+
- `MainLayout::addFooterScript(...)` citeturn0view0
|
|
117
|
+
|
|
118
|
+
Example:
|
|
119
|
+
|
|
120
|
+
```php filename="src/app/index.php"
|
|
121
|
+
<?php
|
|
122
|
+
|
|
123
|
+
use Lib\MainLayout;
|
|
124
|
+
|
|
125
|
+
MainLayout::addHeadScript('<script src="head-script.js"></script>');
|
|
126
|
+
MainLayout::addFooterScript('<script src="footer-script.js"></script>');
|
|
127
|
+
?>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This is not metadata in the strict SEO sense, but it is part of the same page-head management model documented by Prisma PHP.
|
|
131
|
+
|
|
132
|
+
## Favicon, icon, and apple-icon
|
|
133
|
+
|
|
134
|
+
Prisma PHP also documents file conventions for application icons.
|
|
135
|
+
|
|
136
|
+
The docs say that `favicon`, `icon`, and `apple-icon` files let you define icons that appear in places such as:
|
|
137
|
+
|
|
138
|
+
- browser tabs
|
|
139
|
+
- phone home screens
|
|
140
|
+
- search engine results citeturn1view0
|
|
141
|
+
|
|
142
|
+
### Supported icon files
|
|
143
|
+
|
|
144
|
+
The provided Prisma PHP icon docs mention image-file based usage such as:
|
|
145
|
+
|
|
146
|
+
- `.ico`
|
|
147
|
+
- `.jpg`
|
|
148
|
+
- `.png` citeturn1view0
|
|
149
|
+
|
|
150
|
+
### Where to place them
|
|
151
|
+
|
|
152
|
+
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`. citeturn1view0
|
|
153
|
+
|
|
154
|
+
## `favicon.ico`
|
|
155
|
+
|
|
156
|
+
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. citeturn1view0
|
|
157
|
+
|
|
158
|
+
The documented link tag is:
|
|
159
|
+
|
|
160
|
+
```php
|
|
161
|
+
<link rel="icon" href="<?= Request::baseUrl?>/favicon.ico" type="image/x-icon" sizes="16x16">
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This means Prisma PHP already expects the favicon in the standard project location and wires it into the layout automatically. citeturn1view0
|
|
165
|
+
|
|
166
|
+
## Automatic head integration
|
|
167
|
+
|
|
168
|
+
The icon docs say Prisma PHP evaluates these icon files and **automatically adds the appropriate tags to your app’s `<head>` element**. citeturn1view0
|
|
169
|
+
|
|
170
|
+
That is the Prisma PHP equivalent of file-convention-based icon metadata.
|
|
171
|
+
|
|
172
|
+
## Metadata and icons in a full page example
|
|
173
|
+
|
|
174
|
+
```php filename="src/app/products/[slug]/index.php"
|
|
175
|
+
<?php
|
|
176
|
+
|
|
177
|
+
use Lib\MainLayout;
|
|
178
|
+
use PP\Request;
|
|
179
|
+
|
|
180
|
+
$slug = Request::$dynamicParams['slug'] ?? 'product';
|
|
181
|
+
|
|
182
|
+
MainLayout::$title = "Product: " . ucfirst((string) $slug);
|
|
183
|
+
MainLayout::$description = "View product details for " . ucfirst((string) $slug) . ".";
|
|
184
|
+
MainLayout::addCustomMetaData("author", "Prisma PHP");
|
|
185
|
+
MainLayout::addCustomMetaData("keywords", "product, ecommerce, details");
|
|
186
|
+
?>
|
|
187
|
+
|
|
188
|
+
<section>
|
|
189
|
+
<h1><?= htmlspecialchars(ucfirst((string) $slug)) ?></h1>
|
|
190
|
+
<p>Product details page.</p>
|
|
191
|
+
</section>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
This is a good Prisma PHP pattern for route-specific metadata on dynamic pages.
|
|
195
|
+
|
|
196
|
+
## Prisma PHP vs Next.js mental model
|
|
197
|
+
|
|
198
|
+
If you are coming from Next.js, the closest mapping is:
|
|
199
|
+
|
|
200
|
+
| Next.js idea | Prisma PHP equivalent |
|
|
201
|
+
| --------------------------------- | -------------------------------------------------------------------------------------- |
|
|
202
|
+
| `export const metadata = { ... }` | `MainLayout::$title`, `MainLayout::$description`, `MainLayout::addCustomMetaData(...)` |
|
|
203
|
+
| `generateMetadata()` | dynamic metadata set at runtime in the PHP route file |
|
|
204
|
+
| `favicon.ico` in app conventions | `favicon.ico` in the app root with built-in layout support |
|
|
205
|
+
| file-based icon conventions | Prisma PHP `favicon`, `icon`, `apple-icon` file conventions |
|
|
206
|
+
| generated OG image files | not documented on the provided Prisma PHP metadata pages |
|
|
207
|
+
|
|
208
|
+
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. citeturn0view0turn1view0
|
|
209
|
+
|
|
210
|
+
## About Open Graph images
|
|
211
|
+
|
|
212
|
+
The Next.js page title includes OG images, but the provided Prisma PHP docs you linked focus on:
|
|
213
|
+
|
|
214
|
+
- dynamic page metadata through `MainLayout`
|
|
215
|
+
- icon file conventions such as `favicon`, `icon`, and `apple-icon` citeturn0view0turn1view0
|
|
216
|
+
|
|
217
|
+
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.
|
|
218
|
+
|
|
219
|
+
## Good to know
|
|
220
|
+
|
|
221
|
+
- Prisma PHP uses `MainLayout` for dynamic metadata management. citeturn0view0
|
|
222
|
+
- `MainLayout::$title` and `MainLayout::$description` are the main documented page metadata properties. citeturn0view0
|
|
223
|
+
- `MainLayout::addCustomMetaData(...)` adds custom metadata such as `author`. citeturn0view0
|
|
224
|
+
- Metadata should be set before any HTML output. citeturn0view0
|
|
225
|
+
- `MainLayout::addHeadScript(...)` and `MainLayout::addFooterScript(...)` can inject scripts into the page shell. citeturn0view0
|
|
226
|
+
- Prisma PHP supports `favicon`, `icon`, and `apple-icon` file conventions. citeturn1view0
|
|
227
|
+
- `favicon.ico` belongs at the top level of the app directory. citeturn1view0
|
|
228
|
+
- Prisma PHP automatically adds the appropriate icon tags to the document head. citeturn1view0
|