定制 anshu-krishna/template-server 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anshu-krishna/template-server

Composer 安装命令:

composer require anshu-krishna/template-server

包简介

A light-weight framework for serving webpages based on templates

README 文档

README

KriTS is a light-weight framework for serving webpages based on templates.

Under construction. Check later.

Usage:

<?php
use KriTS\Server;
use KriTS\RouteExpression as RE;
use KriTS\RouteNode as RN;

// Initilise the server
/*
Server::init(?string $templates_path = null, ?string $routes_path = null) : void;
*/
Server::init();

// Define the routes
/*
execute(RouteNode $root) : never
*/
Server::execute(new RN(
	"root_start",
	"root",
	"root_end",
	new RE('404', new RN(
		"404_start",
		"404",
		"404_end"
	)))
);

RouteNode:

// Signature:
new \KriTS\RouteNode (
	array|string|null $pre,
	array|string|null $here,
	array|string|null $post,
	RouteExpression ...$next
);

$pre, $here & $post are tempates and can have following values:

  • null: It means there is no template
  • array: One of more string values as described below
  • string: It can be used in following ways
    • Default: plaintext as template.
    • @file_path: loads file at path 'file_path' relative to the default templates_path
    • #file_path: loads file at absolute path 'file_path'

RouteExpression:

// Signature:
new \KriTS\RouteExpression(
	string $exp,
	private RouteNode|string $route
);

$route can be a RouteNode object or a string containing path of route file. If string starts with '@' then file_path is relative to the default routes_path. If string starts with '#' then file_path is absolute.

$exp can have following formats:

  • 'plaintext': matches 'plaintext'
  • '@var1': matches anything. The matched value is assigned to Router::$path_vars list with var1 as key.
  • '@var2=pattern': matches RegExp defined by pattern. The matched value is assigned to Router::$path_vars list with var2 as key.
  • '@var3~pattern': matches RegExp defined by pattern with case-insensitive flag. The matched value is assigned to Router::$path_vars list with var3 as key.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固