PHP code example of anax / proxy

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

    

anax / proxy example snippets


use Anax\Proxy\ProxyDIFactory;

// Add all framework services to $di
$di = new Anax\DI\DIFactoryConfig();
$di->loadServices(ANAX_INSTALL_PATH . "/config/di");

// Add anax/proxy access to $id, if available
ProxyDIFactory::init($di);

// Add anax/proxy access to $id, if available
if (class_exists("\Anax\Proxy\ProxyDIFactory")) {
    \Anax\Proxy\ProxyDIFactory::init($di);
}

use \Anax\Proxy\DI\Db;

use \Anax\Proxy\DI\Db;
use \Anax\Proxy\DI\Router;
use \Anax\Proxy\DI\View;
use \Anax\Proxy\DI\Page;

/**
 * Show all movies.
 */
Router::get("movie", function () {
    $data = [
        "title"  => "Movie database | oophp",
    ];

    Db::connect();

    $sql = "SELECT * FROM movie;";
    $res = Db::executeFetchAll($sql);

    $data["res"] = $res;

    View::add("movie/index", $data);
    Page::render($data);
});

/**
 * Show all movies.
 */
$app->router->get("movie", function () use ($app) {
    $data = [
        "title"  => "Movie database | oophp",
    ];

    $app->db->connect();

    $sql = "SELECT * FROM movie;";
    $res = $app->db->executeFetchAll($sql);

    $data["res"] = $res;

    $app->view->add("movie/index", $data);
    $app->page->render($data);
});