krowinski/laravel-xslt
Composer 安装命令:
composer require krowinski/laravel-xslt
包简介
xslt template engine for laravel
README 文档
README
XSLT template engine for laravel
Instalation
- Install using composer in your laravel project
composer require krowinski/laravel-xslt
- Add this line to app.php at the end of 'providers' array (in file config/app.php)
Krowinski\LaravelXSLT\XSLTServiceProvider::class,
- Create welcome.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:output encoding="UTF-8" method="xml" omit-xml-declaration="yes" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" cdata-section-elements="script"/> <xsl:template match="/"> <head> <title>Laravel</title> <link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css"/> <style> html, body { height: 100%; } body { margin: 0; padding: 0; width: 100%; display: table; font-weight: 100; font-family: 'Lato'; } .container { text-align: center; display: table-cell; vertical-align: middle; } .content { text-align: center; display: inline-block; } .title { font-size: 96px; } </style> </head> <body> <div class="container"> <div class="content"> <div class="title">Laravel 5 XSLT engine template</div> </div> </div> </body> </xsl:template> </xsl:stylesheet>
- Add data to xml using simple xml functions
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { // adds to main xml /App attributte name template with value = hello \View::addAttribute('name_template ', 'hello'); // create child template to /App with value hello and add aaa and zzz atribute to template. \View::addChild('template', 'hello', false)->addAttribute('aaaa', 'zzz'); // creates parent example and adds childs foo and bar to it \View::addArrayToXmlByChild(['foo', 'bar'], 'example', false); // add to parent App child bar and zzz \View::addArrayToXml(['bar', 'zzz'], false); return view('welcome'); }
Add xml to debugBar (https://github.com/barryvdh/laravel-debugbar)
Add to EventServiceProvider.php
use Krowinski\LaravelXSLT\Engines\XSLTEngine;
and to protected $listen array
XSLTEngine::EVENT_NAME => [ 'App\Listeners\XSLTDebugBar' ],
create file Listeners\XSLTDebugBar.php
php artisan make:listener XSLTDebugBar --event XSLTEngineEvent
event content
<?php namespace App\Listeners; use DebugBar\DataCollector\MessagesCollector; use DebugBar\DebugBar; use Illuminate\Support\Facades\App; use Krowinski\LaravelXSLT\Events\XSLTEngineEvent; /** * Class XSLTDebugBar * @package App\Listeners */ class XSLTDebugBar { /** * @param XSLTEngineEvent $event */ public function handle(XSLTEngineEvent $event) { $dom = new \DOMDocument; $dom->preserveWhiteSpace = false; $dom->loadXML($event->getExtendedSimpleXMLElement()->saveXML()); $dom->formatOutput = true; $xmlString = $dom->saveXML(); /** @var DebugBar $debugBar */ $debugBar = App::make('debugbar'); if (!$debugBar->hasCollector('XML')) { $debugBar->addCollector(new MessagesCollector('XML')); } /** @var MessagesCollector $collector */ $collector = $debugBar->getCollector('XML'); $collector->addMessage($xmlString, 'info', false); } }
krowinski/laravel-xslt 适用场景与选型建议
krowinski/laravel-xslt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 977 次下载、GitHub Stars 达 14, 最近一次更新时间为 2015 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「xml」 「template」 「view」 「xslt」 「laravel」 「xsl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 krowinski/laravel-xslt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 krowinski/laravel-xslt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 krowinski/laravel-xslt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Load DOM document safety
Illuminate View for Morningmedley.
Blade template for Kirby
Simple ASCII output of array data
Added a method to Laravel response for handling xml response and also converting Eloquent return to XML.
统计信息
- 总下载量: 977
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-08