dupot/static-management-framework
最新稳定版本:1.0.0
Composer 安装命令:
composer require dupot/static-management-framework
包简介
framework to manage static website
README 文档
README
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(); } }
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2023-04-08