定制 dev-lancer/jpk-generator 二次开发

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

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

dev-lancer/jpk-generator

最新稳定版本:v1.0.3

Composer 安装命令:

composer require dev-lancer/jpk-generator

包简介

PHP library for generating JPK XML documents

README 文档

README

This repository contains a PHP library. A Docker environment using PHP 8 is included to ease development and testing of future scripts.

Requirements

  • Docker
  • Docker Compose

Usage

Build the container and start an interactive PHP shell:

docker compose run --rm app

To run a specific PHP script:

docker compose run --rm app /app/your_script.php

The working directory /app inside the container is mounted from the project root so changes on the host are immediately available in the container.

XML Generation

The library contains an XmlGenerator class capable of transforming a populated Document object into the final JPK XML string. Only fields with non-null values are included in the output and attributes are respected.

<?php
use DevLancer\JPKGenerator\{Document, XmlGenerator};

$document = new Document();
// populate $document with data …

$xml = (new XmlGenerator())->generate($document);
file_put_contents('jpk.xml', $xml);

The generator applies the correct namespace prefixes and recursively serializes nested ParameterBag structures. When a ParameterBag specifies a custom prefix, it takes precedence over the generator's default mapping.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-22