Code Monkey home page Code Monkey logo

dupotstaticmanagementframework's Introduction

dupotStaticManagementFramework

framework to manage a static website created using dupotStaticGenerationFramework

how to use it ?

composer require dupot/static-management-framework
mkdir public
touch public/index.php

In public/index.php, paste this code

<?php

require __DIR__ . '/../vendor/autoload.php';

use Dupot\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);
    }
}

This will be start file for your web application, add a json file to setup your routes

mkdir -p src/conf/
touch src/conf/routing.json

In src/conf/routing.json, paste this code

[
    {
        "pattern": "#/myOtherPage.html#",
        "class": "My\\Infrastructure\\Pages\\OtherPage",
        "method": "index"
    },
    {
        "pattern": "#/#",
        "class": "My\\Infrastructure\\Pages\\HomePage",
        "method": "index"
    }
]

Example of Home page:

<?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();
    }
}

dupotstaticmanagementframework's People

Contributors

imikado avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.