Skip to content

Commit 5907ac7

Browse files
committed
Text
1 parent 6a2069e commit 5907ac7

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,29 +187,39 @@ You can refer to the Ozu demo project [dvlpp/ozu-demo](https://github.com/dvlpp/
187187

188188
## Restrictions
189189

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 cant 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.
191191

192192
### 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+
194196
```php
195197
Route::get('/projects')
196198
```
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).
200205

201206
### 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+
203210
```php
204211
Route::get('/projects/index/{page}')
205212
```
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.
207215

208216
### 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.
210219

211220
### 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).
213223

214224
## Go for production
215225

0 commit comments

Comments
 (0)