ls-a/xml-utils
Composer 安装命令:
composer require ls-a/xml-utils
包简介
Utilities for XML handling: attributes, tags, namespaces, comparison and late evaluation
README 文档
README
This documentation is also available in these languages:
This library provides a simple and readable interface to create and manipulate XML with ease. As many libraries out there, it supports XML structure, but with a very comprehensive API.
Code sample:
<?php // A footnote tag class FootnoteTag extends Tag implements HasDefinition { // This method allows you to customize tag name, if you wish to public function getTagName(): string { return 'footnote'; } // This method allows you to define a strict constraint on this tag public function asDefinition(): Definition { return (new Definition()) // Allowed elements in this tag: `<inline>` and `<footnote-body>` ->sequence(new Sequence( new Element(Inline::class), new Element(FootnoteBody::class), )) // Allowed attributes ->allows([ // An attribute group AccessibilityProperties::class, // A property Id::class, // A typed attribute new TypedAttribute('margin', MarginType::class) ]) // Inherited attributes ->inheritables([ // Another attribute group InheritedProperties::class, ]); } }
Features
This library, as many others, supports:
- Tags (
<block></block>), EmptyTags (<img/>) and TextNodes (content) - Attributes (
key="value") - XML generation out of object structure
But it also supports:
- Properties, meaning an attribute with a Type, that can be validated with a Validator
- Collections, to add/remove/filter/map/reduce Tags and Properties
- AttributeGroup, based on XSD structure
- XPath for complex queries
- Validation for tags (which tag is allowed where), based on XSD structure
- Shorthand attributes, eg
marginformargin-top,margin-left,margin-rightandmargin-bottom - Compound attributes, eg
space-before.minimum="0pt" space-before.maximum="10pt - Inherited attributes to access values from traversal
- Complex validations for Properties: Union, Cumulative, CumulativeOrdered, Intersect, InverseRegex, ...
- XSD compatibility
For each structure, you can use the validate method to check whether the generated structure is correct.
Why?
First, because why not? We could not find an XML library that provides every aspect we needed, especially conformance with XSD and complex validations: we felt it was missing and maybe you would also like it.
Next, for a little background, this package is used in XSL-Core package, to handle various XML function calls in attributes.
Installation
This library is available on Composer. Install it with:
composer require ls-a/xml-utils
Changelog
Please refer to the CHANGELOG file to see the latest changes.
Support
We put our heart into delivering high-quality products that are accessible to everyone. If you like our work, don’t hesitate to reach out to us for your next project!
Contributing
Contributions are governed by the CONTRIBUTING file.
Tests are still missing and we don't have much time to write them now, however this package is considered stable, as it is used by several other packages in our end that have thousands of tests.
Security
If you’ve found a bug or vulnerability, please contact us by email at contact@ls-a.fr instead of opening an issue, in order to protect the security of other users.
Credits
- Renaud Berthier
License
The MIT License (MIT). Please see License File for more information.
ls-a/xml-utils 适用场景与选型建议
ls-a/xml-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 66 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「xml」 「tags」 「utils」 「comparison」 「namespaces」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ls-a/xml-utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ls-a/xml-utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ls-a/xml-utils 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
A powerfull cacher based on laravels file cache driver
Phalcon PHP Meta tags service
n2n test utils
A collection of enhancements and utilities for the Silverstripe UserForms module
Load DOM document safety
统计信息
- 总下载量: 66
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-11-11