PHP code example of ornitophp / framework

1. Go to this page and download the library: Download ornitophp/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/ */

    

ornitophp / framework example snippets



declare(strict_types=1);

define('ORNITO_ROOT', dirname(__DIR__));

$builder = User::query()
    ->where('active', 1)
    ->orderBy('created_at', 'DESC');

echo $builder->toSql();           // SELECT * FROM users WHERE active = ? ORDER BY created_at DESC
print_r($builder->getBindings()); // [1]
echo $builder->toPreviewSql();    // SELECT * FROM users WHERE active = 1 ORDER BY created_at DESC

// This is how every controller works:
public function index(Request $request): Response
{
    return $this->view('home', ['title' => 'Welcome']);
}