jan-drda/pure-php-xml-writer
Composer 安装命令:
composer require jan-drda/pure-php-xml-writer
包简介
Simple XML writer library written with basic PHP functions only.
关键字:
README 文档
README
Pure PHP XML Writer
Simple XML writer library written with basic PHP functions only. The main purpose of this project is generating large XML files without using large amount of memory (all elements are passed to the write buffer, there is no object containing all the XML in memory).
Installation
composer require jan-drda/pure-php-xml-writer
Then copy example.php to your project root directory. You can modify it upon your requirements and run.
If you do not have Composer
Install it, it is very simple: https://getcomposer.org/doc/00-intro.md
Documentantion
Please see example.php for basic usage, I am working at documentation (copying there):
/** * Composer autoload (only if you do not use it anywhere else) * * It is needed for namespace mapping */ require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); /** * Simple initialize XML Writer and auto open the file */ $xmlWriter = new \PurePhpXmlWriter\PurePhpXmlWriter('feed.xml'); /** * Open root element "items" (true = expecting children elements) */ $xmlWriter->openXMLElement('products', true); /** * Save simple product */ $xmlWriter->openXMLElement('product', true); // Open the parent element $xmlWriter->saveElementWithValue('name', 'Breakfast white mug'); // Name $xmlWriter->saveElementWithValue('description', 'Nice white mug used for breakfast'); // Description $xmlWriter->saveElementWithValue('price', 5.00, 2); // Price with 2 decimals $xmlWriter->saveElementWithValue('category', 'Mugs|Breakfast'); // Category $xmlWriter->saveElementWithValue('quantity', 20); // Quantity available $xmlWriter->closeXMLElement('product'); // Close the parent element /** * /Save simple product */ /** * Save variable product where variants have individual prices */ $xmlWriter->openXMLElement('product', true); // Open the parent element $xmlWriter->saveElementWithValue('name', 'Puma T-shirt'); // Name $xmlWriter->saveElementWithValue('description', 'Puma t-shirt with some sizes'); // Description $xmlWriter->saveElementWithValue('price', 10.00, 2); // Price with 2 decimals $xmlWriter->saveElementWithValue('category', 'T-shirts|Nike'); // Category $xmlWriter->saveElementWithValue('quantity', 10); // Quantity available $xmlWriter->openXMLElement('sizes', true); // Open the parent element for sizes // Small size $xmlWriter->openXMLElement('size', true); // Open the parent element for size $xmlWriter->saveElementWithValue('size_name', 'S'); // Size name $xmlWriter->saveElementWithValue('size_price', 10.00); // Size price with 2 decimals $xmlWriter->closeXMLElement('size', true); // Open the parent element for size // Medium size $xmlWriter->openXMLElement('size', true); // Open the parent element for size $xmlWriter->saveElementWithValue('size_name', 'M'); // Size name $xmlWriter->saveElementWithValue('size_price', 11.00); // Size price with 2 decimals $xmlWriter->closeXMLElement('size', true); // Open the parent element for size // Large size $xmlWriter->openXMLElement('size', true); // Open the parent element for size $xmlWriter->saveElementWithValue('size_name', 'L'); // Size name $xmlWriter->saveElementWithValue('size_price', 13.00); // Size price with 2 decimals $xmlWriter->closeXMLElement('size', true); // Open the parent element for size $xmlWriter->closeXMLElement('sizes', true); // Close the parent element for sizes $xmlWriter->closeXMLElement('product'); // Close the parent element /** * /Save variable product */ /** * Close root element "items" */ $xmlWriter->closeXMLElement('products');
jan-drda/pure-php-xml-writer 适用场景与选型建议
jan-drda/pure-php-xml-writer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 255 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「xml」 「pure php」 「xml writer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jan-drda/pure-php-xml-writer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jan-drda/pure-php-xml-writer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jan-drda/pure-php-xml-writer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Object Mapper for Tarantool.
Load DOM document safety
Symfony lock Tarantool store
Added a method to Laravel response for handling xml response and also converting Eloquent return to XML.
Pure is a ridiculously tiny CSS library you can use to start any web project.
Uses reflection to map XML to PHP objects.
统计信息
- 总下载量: 255
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-30