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
Create your routes, controllers, views, etc. as you would do for a regular Laravel project — with a few restrictions in mind, because of the static nature of the project:
26
-
- Do not use any querystring
27
-
- TODO
28
-
- ...
21
+
## Usage
29
22
30
23
### Models are Ozu collections
31
24
@@ -146,7 +139,7 @@ You must define the `model_key` in the relation to differentiate the different t
146
139
147
140
You can then use this relation in your views to display the images, and leverage the `thumbnail()` method to get the URL of the image in the desired size:
@@ -192,6 +185,32 @@ class DatabaseSeeder extends OzuSeeder
192
185
193
186
You can refer to the Ozu demo project [dvlpp/ozu-demo](https://github.com/dvlpp/ozu-demo) for an example of a simple project that uses Ozu.
194
187
188
+
## Restrictions
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.
191
+
192
+
### Query string
193
+
Considering this route
194
+
```php
195
+
Route::get('/projects')
196
+
```
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)
200
+
201
+
### 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 :
203
+
```php
204
+
Route::get('/projects/index/{page}')
205
+
```
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
207
+
208
+
### 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.
210
+
211
+
### Forms
212
+
For forms, in the current state of Ozu, you'll need an external provider to handle submission (like [FieldGoal](https://fieldgoal.io/))
213
+
195
214
## Go for production
196
215
197
216
Once your project is ready, you can deploy it to Ozu.
0 commit comments