定制 transitive/web 二次开发

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

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

transitive/web

Composer 安装命令:

composer require transitive/web

包简介

Web Front controller and view for transitive.

README 文档

README

HTTP front controller and HTML-oriented view layer for Transitive.

This package builds on transitive/core and transitive/routing to provide browser-facing rendering, content negotiation, default HTML layout handling, and helpers for scripts, styles, and metadata.

Latest Stable Version License

Installation

composer require transitive/web

PHP 8.1+ is required.

What is included

  • Transitive\Web\Front: an HTTP front controller with Accept header negotiation and response header management.
  • Transitive\Web\View: a richer (than Transitive\Simple) view implementation with title, meta tag, stylesheet, and script helpers.

Basic Usage

<?php

use Transitive\Web;
use Transitive\Routing;

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

$front = new Web\WebFront();

$front->addRouter(new Routing\PathRouter(dirname(dirname(__FILE__)).'/presenters', dirname(dirname(__FILE__)).'/views'));

$front->execute(@$_GET['request'] ?? 'index');

echo $front;

Response formats

Transitive\Web\Front can emit different representations depending on the resolved content type, including:

  • HTML and XHTML
  • JSON
  • XML
  • YAML
  • raw stylesheet content
  • raw script content
  • serialised document/head/content payloads

By default it inspects $_SERVER['HTTP_ACCEPT'] and chooses the best supported MIME type.

View helpers

Transitive\Web\View extends the simple core view with helpers such as:

  • addMetaTag() / addRawMetaTag()
  • addStyle() / linkStyleSheet() / importStyleSheet()
  • addScript() / linkScript() / importScript()
  • getHead(), getMetas(), getStyles(), and getScripts()

Example:

<?php

use Transitive\Web\View;

$view = new View();
$view->setTitle('Home');
$view->addMetaTag('description', 'Example page');
$view->linkStyleSheet('/assets/site.css');
$view->linkScript('/assets/site.js', defer: true);
$view->addContent(function($data) {
	echo '<h1>Hello '.$data['name'].'</h1>';
}, 'text/html');

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固