Skip to content

Commit 6a2069e

Browse files
author
aguingand
authored
Update README.md
1 parent 1f62606 commit 6a2069e

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ Publish the config file:
1818
php artisan vendor:publish --tag="ozu-client-config"
1919
```
2020

21-
## Getting started
22-
23-
### Routes, controllers, views
24-
25-
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
2922

3023
### Models are Ozu collections
3124

@@ -146,7 +139,7 @@ You must define the `model_key` in the relation to differentiate the different t
146139

147140
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:
148141

149-
```php
142+
```blade
150143
@if(count($project->visuals))
151144
<div class="mt-12">
152145
<div class="grid sm:grid-cols-3 grid-cols-2 gap-4">
@@ -192,6 +185,32 @@ class DatabaseSeeder extends OzuSeeder
192185

193186
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.
194187

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+
195214
## Go for production
196215

197216
Once your project is ready, you can deploy it to Ozu.

0 commit comments

Comments
 (0)