PHP code example of dupot / static-management-framework

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

    

dupot / static-management-framework example snippets

 php


\StaticManagementFramework\Application;
use Dupot\StaticManagementFramework\Http\Request;
use Dupot\StaticManagementFramework\Http\Response;
use Dupot\StaticManagementFramework\Setup\ConfigManager;
use Dupot\StaticManagementFramework\Setup\RouteManager;

try {
    session_start();

    define('ROOT_PATH', __DIR__ . '/../');

    $debug = true;

    $request = new Request([
        Request::SOURCE_GET => $_GET,
        Request::SOURCE_POST => $_POST,
        Request::SOURCE_SESSION => $_SESSION,
        Request::SOURCE_SERVER => $_SERVER
    ]);

    $routeManager = new RouteManager();
    $routeManager->loadConfigFromJson(__DIR__ . '/../src/conf/routing.json');

    $configManager = new ConfigManager();
    //$configManager->loadConfigFromIni(__DIR__ . '/../src/conf/yourConfigFile.ini');

    $configManager->setSectionParam('path', 'root', ROOT_PATH);

    $application = new Application([
        Application::CONFIG_MANAGER => $configManager,
        Application::ROUTE_MANAGER => $routeManager,
        Application::REQUEST => $request,
        Application::RESPONSE => new Response()
    ]);
    $application->run();
} catch (Exception $e) {

    if ($debug) {
        print_r($e, true);
    }
}

 php


namespace My\Infrastructure\Pages;

use Dupot\StaticManagementFramework\Page\PageAbstract;
use Dupot\StaticManagementFramework\Render\Layout;
use Dupot\StaticManagementFramework\Render\View;

class HomePage extends PageAbstract
{
    protected $layout = null;

    public function __construct()
    {
        $this->layout = new Layout(__DIR__ . '/Layouts/default.php');
    }

    public function index()
    {
        //$errorList = $this->processLogin();

        $view = new View(
            __DIR__ . '/View/home.php',
            []
        );

        $this->layout->appendContext('contentList', $view);

        return $this->render();
    }

    public function render()
    {

        echo $this->layout->render();
    }
}