Usage | Overview

There are so many more featuers than what is listed here.

Sample View

You can see many more example views in the tests at test/Server/phad and test/input/views

<route pattern="/blog-list/"></route>  
  
<div item="Blog" >  
    <p-data></p-data>  
    <h1 prop="title"></h1>  
    <p prop="body"></p>  
</div>  

Sample Form

You can see many more example forms in the tests at test/Server/phad/form and test/input/views/Form.

<route pattern="/blog/make/"></route>  
  
  
<form cansubmit="call:can_submit" item="Blog" target="/blog/{slug}/">  
    <onsubmit><?php   
        $slug = strtolower($BlogRow['title']);  
        $slug = str_replace(' ', '-', $slug);  
        $BlogRow['slug'] = $slug;  
  
    ?></onsubmit>  
    <failsubmit><?php  
        // unset($BlogInfo->args['phad']);  
        // print_r($BlogInfo);  
        // print_r($_POST);  
        // // exit;  
        // print_r($BlogRow);  
        // // exit;  
    ?></failsubmit>  
  
    <input type="text" name="title" maxlength="75">  
    <textarea name="body" maxlength="2000" minlength="10"></textarea>  
  
  
    <input type="backend" name="slug" minlength=4 maxlength=150 />  
</form>  

You'll need to add a submit button ...

Server Setup

Example setup code with Liaison

<?php  
  
require_once(__DIR__.'/../AccessHandler.php');  
  
$_GET['user'] = $_GET['user'] ?? 'default-user-role';  
  
$options = [  
    'dir.templates'=>'/phad/',  
    'dir.cache'=>'/cache/',  
    'dir.sitemap'=>'/sitemap/',  
    'query.throw_on_failure'=>true,  
    'compile.force'=>false,  
];  
  
//$phad = \Phad::main($lildb->pdo, $dir, $lia, null, $options);  
  
$router_integration = new \Phad\Integration\LiaisonRouter($lia);  
$access_integration = new \Phad\Test\AccessHandler();  
$phad = \Phad::custom($lildb->pdo, $dir, $router_integration, $access_integration, $options);  
  
$phad->filters['markdown'] = function($v){return 'pretend-this-is-markdown:<p>'.$v.'</p>';};  
  
$phad->setup_routes();  

Upload Files

This isn't integrated well, yet. You have to add some code to your form, like:

<route pattern="/document/make/"></route>  
  
  
<form item="Document" target="/document-list/">  
    <onsubmit><?php  
  
        $DocumentRow['file_name'] = $_FILES['doc']['name'];  
        $DocumentRow['stored_name'] = \Phad\PDOSubmitter::uploadFile($_FILES['doc'],   
            dirname(__DIR__, 2).'/files-uploaded/',  
            ['txt']  
        );  
    ?></onsubmit>  
    <input type="text" name="title" maxlength="75" />  
    <input type="file" name="doc" />  
  
    <input type="backend" name="file_name" />  
    <input type="backend" name="stored_name" />  
</form>  

Simple Example

<route pattern="/blog/{slug}/"></route>  
<div item="Blog" >  
    <p-data where="Blog.slug LIKE :slug"></p-data>  
    <h1 prop="title"></h1>  
    <x-prop prop="body" filter="commonmark:markdownToHtml"></x-prop>  
</div>  

File Uploads

test/Server/phad/form/document.php
idk what to say. here's an example. Notice how i modify the document row & add the type=backend nodes

<route pattern="/document/make/"></route>  
<form item="Document" target="/document-list/">  
    <onsubmit><?php  
        $DocumentRow['file_name'] = $_FILES['doc']['name'];  
        $DocumentRow['stored_name'] = \Phad\PDOSubmitter::uploadFile($_FILES['doc'],   
            dirname(__DIR__, 2).'/files-uploaded/',  
            ['txt']  
        );  
    ?></onsubmit>  
    <input type="text" name="title" maxlength="75" />  
    <input type="file" name="doc" />  
  
    <input type="backend" name="file_name" />  
    <input type="backend" name="stored_name" />  
</form>