PHP code example of wazi / framework

1. Go to this page and download the library: Download wazi/framework library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wazi / framework example snippets




use Psr\Http\Message\ServerRequestInterface;
use Wazi\Http\Response;
use Wazi\Kernel\Kernel;

uest) {
    $id = $request->getAttribute('id');   // un int, garanti par la contrainte

    return new Response(200, ['Content-Type' => 'text/plain; charset=utf-8'], "Article n° $id");
});

$app->run();

final readonly class NoteController
{
    public function __construct(private Database $db, private Kioo $kioo) {}

    #[Get('/notes/{id:int}')]
    public function voir(int $id): ResponseInterface
    {
        $note = $this->db->selectOne('SELECT * FROM notes WHERE id = ?', [$id]);

        return $this->kioo->page('note', ['note' => $note]);
    }
}
bash
php -S localhost:8000 examples/bonjour.php          # un seul fichier, des routes écrites comme des fonctions
php -S localhost:8000 examples/carnet/index.php     # un contrôleur, un service, des pages en Kioo
cd examples/demo && php wazi serve                  # une application complète, rangée comme un vrai projet