定制 vitexsoftware/pohodaser 二次开发

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

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

vitexsoftware/pohodaser

最新稳定版本:0.1.2

Composer 安装命令:

composer require vitexsoftware/pohodaser

包简介

Stormware's Pohoda XML/PHP serialization

README 文档

README

wakatime

Stormware's Pohoda XML/PHP serializer.

This library provides a PHP-based solution for serializing and deserializing XML data for Stormware's Pohoda accounting software. It is designed to work with Pohoda's XML schema definitions (XSD) and simplifies the process of integrating Pohoda's data exchange into your PHP applications.

Features

  • XML Serialization: Convert PHP objects into Pohoda-compatible XML.
  • XML Deserialization: Parse Pohoda XML files into PHP objects.
  • XSD Integration: Automatically maps XML schema definitions to PHP classes.
  • Customizable: Extend and modify the library to fit your specific Pohoda integration needs.

Requirements

Installation

Install the library using Composer:

composer require vitexsoftware/pohodaser

XSD Taken from https://www.stormware.cz/xml/schema/all_schema_ver2.zip

Example Usage

Serialize an Invoice Object to XML

use Pohoda\Invoice\Invoice;
use Pohoda\XML\SerializerBuilder;

// Create an instance of the serializer
$serializer = SerializerBuilder::create()->build();

// Create an invoice object
$invoice = new InvoiceType();
$invoice->setId(123);
$invoice->setName('Sample Invoice');

// Serialize the object to XML
$xmlContent = $serializer->serialize($invoice, 'xml');

echo $xmlContent;

Deserialize XML to an Invoice Object

use Pohoda\Invoice\InvoiceType;
use Pohoda\XML\SerializerBuilder;

// Create an instance of the serializer
$serializer = SerializerBuilder::create()->build();

// Load XML content
$xmlContent = file_get_contents('path/to/invoice.xml');

// Deserialize the XML into a PHP object
$invoice = $serializer->deserialize($xmlContent, InvoiceType::class, 'xml');

print_r($invoice);

Detect and Deserialize XML to a PHP Object

use Pohoda\Xml\Helper;
use Pohoda\XML\SerializerBuilder;

$serializer = SerializerBuilder::create()->build();
$xmlContent = file_get_contents('path/to/faktury_03_v2.0.xml');

// Detect the PHP class name from the XML
$phpClassName = Helper::xml2ns($xmlContent);

if ($phpClassName) {
    $object = $serializer->deserialize($xmlContent, $phpClassName, 'xml');
    print_r($object);
} else {
    echo "Namespace not found for the root element.\n";
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-18