bupy7/xml-constructor
Composer 安装命令:
composer require bupy7/xml-constructor
包简介
The array-like constructor of XML document structure.
README 文档
README
The array-like constructor of XML document structure.
Supporting PHP from 5.6 up to newest.
Install
Add the following to require section of your composer.json:
"bupy7/xml-constructor": "*"
Then do composer install;
or execute the command:
$ composer require bupy7/xml-constructor
Usage
Input:
$xml = new XmlConstructor(); $in = [ [ 'tag' => 'root', 'elements' => [ [ 'tag' => 'tag1', 'attributes' => [ 'attr1' => 'val1', 'attr2' => 'val2', ], ], [ 'tag' => 'tag2', 'content' => 'content2', ], [ 'tag' => 'tag3', 'elements' => [ [ 'tag' => 'tag4', 'content' => 'content4', ], ], ], [ 'tag' => 'tag4', 'content' => '<b>content4</b>', 'cdata' => true, // by default - false, see https://en.wikipedia.org/wiki/CDATA ], ], ], ]; echo $xml->fromArray($in)->toOutput();
Output:
<?xml version="1.0" encoding="UTF-8"?> <root> <tag1 attr1="val1" attr2="val2"/> <tag2>content2</tag2> <tag3> <tag4>content4</tag4> </tag3> <tag4><![CDATA[<b>content4</b>]]></tag4> </root>
Configuration:
$xml = new XmlConstructor([ // Indent each line in the XML document. 4 space by default. 'indentString' => ' ', /* Header document tag. "<?xml version="1.0" encoding="UTF-8"?>" by default. */ 'startDocument' => [ // version '1.0', // encoding 'UTF-8', ], ]);
You can set up indentString and/or startDocument as null to disable them.
Testing
Run tests:
$ ./vendor/bin/phpunit --no-coverage
Run tests with coverage:
$ XDEBUG_MODE=coverage ./vendor/bin/phpunit
HTML coverage path: build/coverage/index.html
Code style
To fix code style, run:
~/.composer/vendor/bin/php-cs-fixer fix --verbose
You have to install PHP CS Fixer at first, if you don't use build-in Docker image:
composer global require friendsofphp/php-cs-fixer
License
xml-constructor is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.
bupy7/xml-constructor 适用场景与选型建议
bupy7/xml-constructor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39.49k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「xml」 「library」 「xml constructor」 「xml writter」 「xml maker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bupy7/xml-constructor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bupy7/xml-constructor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bupy7/xml-constructor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Load DOM document safety
Inbox pattern process implementation for your Laravel Applications
Added a method to Laravel response for handling xml response and also converting Eloquent return to XML.
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
统计信息
- 总下载量: 39.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-07-19