ml-express/xml
最新稳定版本:0.1
Composer 安装命令:
composer require ml-express/xml
包简介
Clacy Builders XML Express is a library for creating XML documents.
README 文档
README
Installation
XML Express for PHP requires PHP 5.4 or newer.
Add the following to your project's composer.json file:
{
"minimum-stability": "dev",
"require": {
"clacy-builders/xml": "dev-master@dev"
}
}
Run composer install or composer update.
Without Composer
- Download the ZIP file.
- Inside your project directory create the directories
/vendor/clacy-builders/xml. - From the folder
xml-express-php-masterinside the ZIP file copy the files it contains into the previously createdxmlfolder.
Replace
require_once 'vendor/autoload.php';
with
require_once 'vendor/clacy-builders/xml/allIncl.php';
Basic Usage
<?php require_once 'vendor/autoload.php'; use \ClacyBuilders\Xml; class Kml extends Xml { const MIME_TYPE = 'application/vnd.google-earth.kml+xml'; const FILENAME_EXTENSION = 'kml'; const XML_NAMESPACE = 'http://www.opengis.net/kml/2.2'; public static function createKml() { return static::createRoot('kml'); } public function placemark($name, $description, $longitude, $latitude, $altitude = 0) { $pm = $this->append('Placemark'); $pm->append('name', $name); $pm->append('description', $description); $pm->append('Point') ->append('coordinates', $longitude . ',' . $latitude . ',' . $altitude); return $pm; } } $myKml = Kml::createKml(); $myKml->placemark('Cologne Cathedral', 'Cologne Cathedral is a Roman Catholic cathedral in Cologne, Germany.', '50.9413', '6.958'); $myKml->headerfields('cologne-cathedral'); print $myKml;
The generated markup:
<?xml version="1.0" encoding="UTF-8" ?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark> <name>Cologne Cathedral</name> <description>Cologne Cathedral is a Roman Catholic cathedral in Cologne, Germany.</description> <Point> <coordinates>50.9413,6.958,0</coordinates> </Point> </Placemark> </kml>
The Adhoc trait
Adhoc allows you to use any method name not previously defined to add XML elements or attributes.
<?php require_once 'vendor/autoload.php'; use \ClacyBuilders\Xml; use \ClacyBuilders\Adhoc; class Html extends Xml { use Adhoc; const XML_DECLARATION = false; const DOCTYPE = '<!DOCTYPE html>'; const HTML_MODE = true; public static function createHtml($lang = null, $manifest = null) { return static::createRoot('html') ->attrib('lang', $lang) ->setManifest($manifest); } } $html = Html::createHtml('en'); $body = $html->body(); $article = $body->article(); $article->h1('Scripting languages'); $article->p(Html::abbr('PHP')->setTitle('PHP: Hypertext Preprocessor') . ' is a server-side scripting language designed for web development but also used as a general-purpose programming language.'); print $html;
The generated markup:
<!DOCTYPE html> <html lang="en"> <body> <article> <h1>Scripting languages</h1> <p><abbr title="PHP: Hypertext Preprocessor">PHP</abbr> is a server-side scripting language designed for web development but also used as a general-purpose programming language.</p> </article> </body> </html>
ml-express/xml 适用场景与选型建议
ml-express/xml 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 282 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 09 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「xml」 「builder」 「writer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ml-express/xml 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ml-express/xml 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ml-express/xml 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple RSS generator library for PHP 5.5 or later. clone from Bhaktaraz Bhatta ttps://github.com/bhaktaraz/php-rss-generator
A Sphinx Query Builder extension for the Laravel Database package
Anax Database Active Record module for model classes.
Load DOM document safety
A simple package to create tables in Discord messages.
laravel facade to read/write csv file
统计信息
- 总下载量: 282
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-17