gulios/xsl-laravel-template-engine
Composer 安装命令:
composer require gulios/xsl-laravel-template-engine
包简介
Xslt template engine for laravel. Based on krowinski/laravel-xslt.
README 文档
README
This is modified version of https://github.com/krowinski/laravel-xslt
Changes:
- added default preferences to XML(paths, language info) depends on config data
- changed method names
- validate input values(htmlentities)
- validate loaded xml(html_entity_decode)
- removed forms
- removed breadcrumbs
Installation:
Add to composer.json
"gulios/xsl-laravel-template-engine": "dev-master"
for debug XML install:
"barryvdh/laravel-debugbar": "2.1.1",
Add this line to config/app.php 'providers' array
'Gulios\LaravelXSLT\XSLTServiceProvider',
Example Usage:
Create main.xsl in resources/views
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE stylesheet [
<!ENTITY nbsp " " ><!-- space -->
<!ENTITY copy "©" ><!-- copyright -->
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" xmlns:str="http://exslt.org/strings" xmlns:php="http://php.net/xsl" exclude-result-prefixes="exslt str php">
<xsl:output encoding="UTF-8" method="html" omit-xml-declaration="yes" indent="yes"
doctype-system="about:legacy-compat" cdata-section-elements="script"/>
<xsl:variable name="curretLanguage"><xsl:value-of select="/App/Preferences/language/@current"/></xsl:variable>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$curretLanguage}" lang="{$curretLanguage}">
<head>
</head>
<body>
<xsl:apply-templates select="/App/Controller"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Create index.xsl in resources/views
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" xmlns:str="http://exslt.org/strings" xmlns:php="http://php.net/xsl" exclude-result-prefixes="exslt str php">
<xsl:import href="main.xsl" />
<xsl:template match="*">
<h2><xsl:value-of select="{$curretLanguage}"/></h2>
</xsl:template>
</xsl:stylesheet>
Add to app/Http/routes.php
Route::get('/', ['as' => 'index', 'uses' => 'SomeController@index']);
Write some test controller AlwaysProcessController.php in app/Http/Controllers
class AlwaysProcessController extends Controller
{
protected $xml;
public function __construct()
{
$this->xml = \View::addChild('Controller');
$this->xml->addAttribute('class', Route::currentRouteAction());
$this->xml->addAttribute('function', Route::currentRouteName());
}
}
after that create SomeController in app/Http/Controllers:
namespace App\Http\Controllers;
use App\Http\Requests;
class SomeController extends AlwaysProcessController
{
public function index()
{
//$this->xml->addChild('SomeTagName', 'SomeValue');
//$this->xml->addData($ibanezImages, $someArrayData);
return view('index');
}
}
Optional
You can add to config/app.php
'available_languages' => array('en','pl'),
'default_language' => 'en',
then you will get these data to XML by default.
Example XML
<?xml version="1.0"?>
<App>
<Controller class="App\Http\Controllers\SomeController@index" function="index">
<SomeTagName>SomeValue</SomeTagName>
</Controller>
<Preferences>
<url isHttps="" currentUrl="http://www.domain/" baseUrl="http://www.domain" previousUrl="http://www.domain/"/>
<server curretnYear="2016" curretnMonth="02" curretnDay="04" currentDateTime="2016-02-04 14:21:56"/>
<language current="en" default="en">
<item>en</item>
<item>pl</item>
</language>
</Preferences>
</App>
gulios/xsl-laravel-template-engine 适用场景与选型建议
gulios/xsl-laravel-template-engine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 125 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「view」 「xslt」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gulios/xsl-laravel-template-engine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gulios/xsl-laravel-template-engine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gulios/xsl-laravel-template-engine 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Symfony 2 / 3 Apache FOP Bundle
Illuminate View for Morningmedley.
Blade template for Kirby
Simple ASCII output of array data
View5 is a version of Blade Templates for the Mvc5 Framework
统计信息
- 总下载量: 125
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-04