Skip to content

Commit

Permalink
Merge pull request #28 from atgp/refactor
Browse files Browse the repository at this point in the history
⚠️ [BC] Refactor for v2
  • Loading branch information
benito103e authored Nov 7, 2023
2 parents c3eb356 + 7707f35 commit 7d253ee
Show file tree
Hide file tree
Showing 11 changed files with 641 additions and 558 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'psr_autoloading' => true,
'visibility_required' => ['elements' => ['property', 'method']],
])
->setRiskyAllowed(true)
->setFinder($finder)
Expand Down
11 changes: 3 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ CONTRIBUTING
Coding standards
----------------

We use the config file **.php_cs.dist** with the version **v2.2** of **friendsofphp/php-cs-fixer**.
We use the config file **.php_cs.dist** with the version **v3** of **friendsofphp/php-cs-fixer**.

Display proposed fixes without changing files
```bash
php-cs-fixer fix -v --dry-run ./
vendor/bin/php-cs-fixer fix -v --dry-run
```

Apply the proposed fixes
```bash
php-cs-fixer fix -v ./
```

If **php-cs-fixer** is not globally installed, you can run the command :
```bash
vendor/bin/php-cs-fixer fix -v ./
vendor/bin/php-cs-fixer fix -v
```

54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
PHP Factur-X library
------------------
Factur-X is the e-invoicing standard for France and Germany. The Factur-X specifications are available on the FNFE-MPE website. The Factur-X standard is also called ZUGFeRD 2.0 in Germany.

Factur-X is a Franco-German e-invoicing standard which complies with the European e-invoicing standard [EN 16931](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/Obtaining+a+copy+of+the+European+standard+on+eInvoicing).
The Factur-X specifications are available on the [FNFE-MPE](http://fnfe-mpe.org/factur-x/) website in English and French.
The Factur-X standard is also called [ZUGFeRD 2.2](https://www.ferd-net.de/standards/zugferd-2.2/zugferd-2.2.html) in Germany.

This library enable you to manage your Factur-X PDF invoices files :
* **Generate Factur-X PDF invoice** from regular PDF invoice and Factur-X XML file
* **Extract Factur-X XML** from Factur-X PDF invoice
* **Check Factur-X XML** against the official Factur-X XML Schema Definition
* **Validate Factur-X XML** against the official Factur-X XML Schema Definition

Table of contents:
------------------
Expand All @@ -14,12 +17,12 @@ Table of contents:
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)
- [Changelog](#changelog)
- [Contributing](CONTRIBUTING.md)

Requirements
------------
- Apache2
- PHP 5.6+
- PHP 7.4+
- Composer
- [FPDI](https://github.com/Setasign/FPDI) (MIT License)
- [Smalot](https://github.com/smalot/pdfparser) (LGPL License)
Expand All @@ -28,7 +31,7 @@ Requirements
Installation
------------

#### Download with Composer
#### Install with Composer

```bash
composer require atgp/factur-x
Expand All @@ -37,24 +40,45 @@ composer require atgp/factur-x
Usage
-----
You can see the code from test page from "tests" directory, also here some simple examples of implementation :

```php
<?php
// Include or autoload (with Composer) all library classes

// Generating Factur-X PDF invoice from PDF and Factur-X XML
$facturx = new Facturx();
$facturxPdf = $facturx->generateFacturxFromFiles($pdf, $facturxXml);
// Generates Factur-X PDF invoice from PDF and Factur-X XML
$writer = new \Atgp\FacturX\Writer();
$facturxPdf = $writer->generate($pdf, $facturxXml);

// Extract Factur-X XML
$facturx = new Facturx();
$facturxXml = $facturx->getFacturxXmlFromPdf($facturxPdf);
// Extracts Factur-X XML
$reader = new \Atgp\FacturX\Reader();
$facturxXml = $reader->extractXML($facturxPdf);

// Check Factur-X XML against official Factur-X XML Schema Definition
$facturx = new Facturx();
$isValid = $facturx->checkFacturxXsd($facturxXml);
// Validates Factur-X XML against official Factur-X XML Schema Definition
$validator = new \Atgp\FacturX\XsdValidator();
if (false === ($isValid = $validator->validate($facturxXml)) {
var_dump($validator->getErrors());
}
// ... or throw exceptions if error(s) are occurred
$validator->validateWithException($facturxXml);
```
More options are available, look at source code for more informations

More options are available, look at source code for more information.

License
-------
This project is licensed under MIT License

Changelog
---------

- v2.0.0 [BC] : 2023-11-06
- Requires php 7.4+
- Refactor classes to clarify uses
- Simplify requirements for "smalot/pdfparser"
- Import external links on generated factur-x pdf
- v1.1.0 : 2019-01-09
- Upgrade Factur-x xsd to v1.0.06
- Fix PDF-A compliance regarding endobj and ICC profile
- v1.0.0 : 2019-01-09
- Requires php 5.6+
- First version of the library to read, check and write factur-x documents
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"type": "library",
"authors": [
{
"name": "Lucas Gouy-Pailler",
"email": "lucas.gouypailler@atgp.net"
"name": "@GP",
"homepage": "https://www.atgp.net/"
}
],
"autoload": {
Expand All @@ -23,14 +23,17 @@
}
},
"require": {
"php": ">=5.6",
"php": ">=7.4",
"setasign/fpdf": "^1.8",
"setasign/fpdi": "^2.0",
"smalot/pdfparser": "^0.19.0",
"smalot/pdfparser": "^0.19.0|~1.0|~2.0",
"ext-dom": "*",
"ext-simplexml": "*",
"ext-libxml": "*",
"ext-zlib": "*",
"ext-fileinfo": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~3.1"
}
}
Loading

0 comments on commit 7d253ee

Please sign in to comment.