13: Bijlagen

Deze bijlagen geven compacte voorbeelden die overeenkomen met de productie-release.

13.1: Basis route met een view

prop title = 'Welkom'

route both GET => view($this)

view:
<main>
    <h1>$this->title</h1>
</main>

13.2: Route met een variabele

route both GET product $id => $this->product($id)

method product($id){
    $record = product::record(id: $id) ?? http_response_code(404)
    view($this->productView, $record)
}

view productView($record):
<article>
    <h1>$record->title</h1>
</article>

13.3: Asynchrone formulier

route both GET contact => view($this)
route async POST contact @name,email,message => $this->send

method send {
    %payload->name || error('Naam is vereist')
    return ['html' => ['#status' => 'Verzonden']]
}

view:
<form method=post action="/contact" class=async>
    <input name=name>
    <input name=email>
    <textarea name=message></textarea>
    <button>Verzenden</button>
</form>
<p#status/>

13.4: Minimale app.json

{
    "resources": [
        "payload",
        "session",
        "security/security",
        "security/token",
        "tag",
        "phlo.async",
        "DOM/form"
    ],
    "release": "%app/release/"
}

13.5: Dev entrypoint

<?php
require('/srv/phlo/phlo.php');
phlo_app (
    id: 'Voorbeeld',
    host: 'dev.example.nl',
    auth: true,
    build: true,
    debug: true,
    app: '/srv/example.nl/',
    data: '/srv/example.nl/data/',
);

13.6: Release entrypoint

<?php
require('/srv/phlo/phlo.php');
phlo_app (
    id: 'Voorbeeld',
    host: 'example.nl',
    app: '/srv/example.nl/release/',
    php: '/srv/example.nl/release/',
    data: '/srv/example.nl/data/',
);

We gebruiken essentiële cookies om deze site te laten werken. Met uw toestemming gebruiken we ook analytics om de site te verbeteren.