You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -187,29 +187,39 @@ You can refer to the Ozu demo project [dvlpp/ozu-demo](https://github.com/dvlpp/
187
187
188
188
## Restrictions
189
189
190
-
Generating static files means we can't use request-specific features like query parameters, session, POST forms, etc... but we provide solutions to keep the code closest to PHP server Laravel app.
190
+
Generating static files means we can’t use request-specific features like query parameters, session, POST forms, etc. But Ozu provides solutions to keep the code as close to a classic Laravel app as possible.
191
191
192
192
### Query string
193
-
Considering this route
193
+
194
+
Consider this simple use case: we need to display a project list that we want to be sortable. In a classic Laravel app, we would have a route like this:
195
+
194
196
```php
195
197
Route::get('/projects')
196
198
```
197
-
When going to `/projects?sort=asc`, we can't check for `sort` in the controller because we are generating static HTML files. Instead you'll need to either :
198
-
- put the query in a param instead (`/projects/list/{sort}`), this will create 2 HTML files `projects/list/desc.html` & `projects/list/asc.html`
199
-
- or handle query string in front-end code (with alpine for example)
199
+
200
+
And in the controller, we would check for a query parameter to sort the projects, for instance `/projects?sort=asc`.
201
+
202
+
In an Ozu project, like for any static website, we can't check for `sort` in the controller because we are generating static HTML files; you can instead:
203
+
- put the query in a param (eg: `/projects/list/{sort}`): this will create 2 HTML files `projects/list/desc.html` and `projects/list/asc.html`.
204
+
- Or handle the query string in front-end code (with Alpine for example).
200
205
201
206
### Pagination
202
-
For the reason enounced above, `?page=1` can't work with generated static HTML. Instead you'll need to put the page as parameter :
207
+
208
+
For the very same reason, `?page=1` can't work with generated static HTML; instead you'll need to put the page as a segment:
209
+
203
210
```php
204
211
Route::get('/projects/index/{page}')
205
212
```
206
-
You can still use `{{ $projects->links() }}` or `route('projects.index', ['page' => 2])`. We override laravel default Paginator to handle the `{page}` parameter instead of a query
213
+
214
+
You will still be able to use `{{ $projects->links() }}` or `route('projects.index', ['page' => 2])`: Ozu overrides Laravel default Paginator to handle the page as a segment.
207
215
208
216
### Session
209
-
By principle, sessions aren't available for static generated sites. If you really need to store session data, you can use cookies or localStorage in JS.
217
+
218
+
By definition sessions aren’t available for static generated sites. If you really need to store session data you can use cookies or localStorage in JS.
210
219
211
220
### Forms
212
-
For forms, in the current state of Ozu, you'll need an external provider to handle submission (like [FieldGoal](https://fieldgoal.io/))
221
+
222
+
For forms, in the current state of Ozu, you'll need an external provider to handle submission (there are a lot of solutions, like [FieldGoal](https://fieldgoal.io/) for instance).
0 commit comments