PHP code example of lhsazevedo / restatic

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

    

lhsazevedo / restatic example snippets


class HomeController
{
    public function __invoke()
    {
        // It just works!
        return View::render('home.index', [
            'articles' => DB::query('SELECT * FROM articles')
        ]);
    }
}

$container = new \DI\Container();
$container->set('db', function () {
    return new PDO('mysql:dbname=testdb;host=127.0.0.1', 'dbuser', 'dbpass');
});

// app/Facades/DB.php

class DB extends StaticProxy
{
    public static function getInstanceIdentifier()
    {
        return 'db';
    }
}

$proxyManager = new ProxyManager($container);
$proxyManager->addProxy('DB', DB::class);
$proxyManager->addProxy('View', View::class);
$proxyManager->enable(ProxyManager::ROOT_NAMESPACE_ANY);