定制 i4erkasov/phalcon-xml-annotations 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

i4erkasov/phalcon-xml-annotations

最新稳定版本:v1.0.0

Composer 安装命令:

composer require i4erkasov/phalcon-xml-annotations

包简介

Phalcon XML Annotations

README 文档

README

Latest Stable Version Total Downloads Packagist PHP Version License

Phalcon XML Annotations is a library that allows you to convert PHP objects into XML files. It provides annotations to define the structure and parameters of XML files based on PHP objects.

Installation

You can install the Phalcon XML Annotations library using Composer. Simply run the following command in your project:

composer require i4erkasov/phalcon-xml-annotations

Documentation

⚠️ Documentation is under development: This library is actively being developed, and documentation is currently being created. We apologize for any inconvenience. Please refer to the source code and examples for usage instructions and implementation details. Thank you for your understanding.

Usage Example

See the example directory for context.

Code:

<?php

use ExamplePhalconXML\IrishPub;
use I4\Phalcon\XML\Analyzer;
use I4\Phalcon\XML\XmlAnnotations;
use Phalcon\Annotations\Adapter\Memory;

$annotations = new XmlAnnotations(
    new Analyzer(new Memory())
);

$xml = $annotations->parse(
    new IrishPub(
        'The Shamrock Pub',
        'Dublin, Ireland',
        '10:00 AM',
        '2:00 AM'
    )
);

$xml->setExtraAttributes([
    'Beer' => [
        'Date' => (new DateTime('now'))->format('Y-m-d'),
    ]
]);

echo $xml->getString(); // Returns the XML as a string

echo $xml->save('/tmp/file.xml'); // Saves the generated XML to a file

Result:

<?xml version="1.0" encoding="UTF-8"?>
<XML>
  <IrishPub Name="The Shamrock Pub" Address="Dublin, Irelan" OpeningTime="10:00 AM" ClosingTime="2:00 AM">
      <![CDATA[Irish Pub]]>
    <BeerList>
      <Beer Date="2023-06-02" Brand="Guinness" Type="Stout" ABV="4.2" Country="Ireland"/>
      <Beer Date="2023-06-02" Brand="Smithwick's" Type="Red Ale" ABV="4.5" Country="Ireland"/>
      <Beer Date="2023-06-02" Brand="Harp Lager" Type="Lager" ABV="4.5" Country="Ireland"/>
    </BeerList>
  </IrishPub>
</XML>

Contributions

You can contribute to the development of this library by creating issues, suggesting new features, and submitting pull requests to the GitHub repository.

License

Phalcon XML Annotations is released under the MIT License.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-28