定制 robertogallea/php-fatturapa 二次开发

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

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

robertogallea/php-fatturapa

最新稳定版本:0.2.7

Composer 安装命令:

composer require robertogallea/php-fatturapa

包简介

Php package for Fattura Elettronica PA

README 文档

README

php-fatturapa is a php implementation for FatturaPA XML specification. It allows reading from and writing to files formatted as described in the current specifications

1. Installation

To install php-fatturapa, require it using composer:

composer require robertogallea/php-fatturapa 

2. Usage

php-fatturapa currently supports only the Fattura Ordinaria model (not Fattura Semplificata)

The whole DOM of the XML document is wrapped by the class FatturaOrdinaria, which could be used directly or build using FatturaPA class.

Follow some basic usage exmaples:

2.1 Read From XML document file

/*   
 * Read from XML
 */
 $filename = 'IT01234567890_FPA01.xml';
 $fattura = FatturaPA::readFromXML($filename); 

2.2 Read From signed XML file

/*   
 * Read from XML signed document
 */
 $filename = 'IT01879020517_e4duu.xml.p7m';
 $fattura = FatturaPA::readFromSignedXML($filename); 

2.3 Read From XML string

/*   
 * Read from XML string
 */
 $xml = '<your-xml-string>';
 $fattura = FatturaPA::readFromXMLString($xml); 

2.4 Write to XML file

/*   
 * Read from XML
 */
 $filename = 'IT01234567890_FPA01.xml';
 FatturaPA::writeToXML($fattura, $filename); 

2.5 Write to XML string

/*   
 * Write to XML string
 */
 $xml = FatturaPA::writeToXMLString($fattura); 

3. Attachment handling

php-fatturapa provides methods for easily add and extract attachments to and from the XML document.
By specifications they are stored inside the FatturaElettronicaBody element, so theFatturaElettronicaBody class provides convenient methods for storing attachments performing the required compresson and base64 encoding:

/*   
 * Export attachments to folder
 */
 $filename = 'IT01234567890_FPA01.xml';
 $fattura = FatturaPA::readFromXML($filename);
 $folder = '/your/path';  
 
 foreach ($fattura->getFatturaElettronicaBody() as $body);
   $body->esportaAllegati($folder);
 }
/*   
 * Add attachment
 */
 $filename = 'IT01234567890_FPA01.xml';
 $fattura = FatturaPA::readFromXML($filename);
 $attachment_filename = /path/to.pdf;
 $attachment = Allegati::createFromFile($attachment_filename,'Name','Description');
 $fattura->getFatturaElettronicaBody()[0]->addAttachment($attachment);
 

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-03-19