{"id":37004165,"url":"https://github.com/mahdiabderraouf/facturx-php","last_synced_at":"2026-01-14T00:36:53.617Z","repository":{"id":269297367,"uuid":"894519296","full_name":"mahdiabderraouf/facturx-php","owner":"mahdiabderraouf","description":"A PHP library for managing Factur-x/ZUGFeRD compliant PDF invoices.","archived":false,"fork":false,"pushed_at":"2025-01-02T20:30:27.000Z","size":343,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T12:00:11.640Z","etag":null,"topics":["e-invoice","factur-x","pdf","php","zugferd"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mahdiabderraouf.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-26T13:53:53.000Z","updated_at":"2025-01-02T20:29:50.000Z","dependencies_parsed_at":"2024-12-22T15:16:55.262Z","dependency_job_id":"621b7ce8-25aa-464b-a732-36ec6f9b7565","html_url":"https://github.com/mahdiabderraouf/facturx-php","commit_stats":null,"previous_names":["mahdiabderraouf/facturx-php"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/mahdiabderraouf/facturx-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdiabderraouf%2Ffacturx-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdiabderraouf%2Ffacturx-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdiabderraouf%2Ffacturx-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdiabderraouf%2Ffacturx-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mahdiabderraouf","download_url":"https://codeload.github.com/mahdiabderraouf/facturx-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdiabderraouf%2Ffacturx-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e-invoice","factur-x","pdf","php","zugferd"],"created_at":"2026-01-14T00:36:53.009Z","updated_at":"2026-01-14T00:36:53.606Z","avatar_url":"https://github.com/mahdiabderraouf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Factur-X PHP\nA PHP library for managing Factur-x/ZUGFeRD compliant PDF invoices.\n\n## Table of Contents\n- [Factur-X PHP](#factur-x-php)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n    - [Using composer](#using-composer)\n  - [Documentation](#documentation)\n  - [Usage](#usage)\n    - [Generate minimum profile XML](#generate-minimum-profile-xml)\n    - [Validate XML against XSD](#validate-xml-against-xsd)\n    - [Generate a Factur-X PDF](#generate-a-factur-x-pdf)\n    - [Parse Factur-X PDF](#parse-factur-x-pdf)\n  - [Bug reports](#bug-reports)\n  - [Contributions](#contributions)\n  - [Roadmap](#roadmap)\n\n---\n\n## Features\n- **XML generation:** Generate Factur-X XML file from an `Invoice` object, supports `minimum`, `basicwl` and `basic` profiles.\n- **PDF generation:** Generate PDF-A3b Factur-X invoice from a given PDF file and a generated/provided XML file.\n- **XML validation:** Validates Factur-X XML against the offical Extension Schema Definition (XSD).\n- **Parsing:** Extract XML file from a Factur-X.\n\n---\n\n## Requirements\n- PHP version: `\u003e= 8.2`\n- [poppler-utils](https://tracker.debian.org/pkg/poppler) for XML extraction\n\n---\n\n## Installation\n\n### Using composer\n```bash\ncomposer require mahdiabderraouf/facturx-php\n```\n\n---\n\n## Documentation\nThe full documentation can be found [here](../../wiki).\n\n---\n\n## Usage\nHere are some quick examples of usage. For advanced usage please refer to the [documentation](../../wiki)\n\n### Generate minimum profile XML\n```php\nuse MahdiAbderraouf\\FacturX\\Builder;\nuse MahdiAbderraouf\\FacturX\\Enums\\Profile;\nuse MahdiAbderraouf\\FacturX\\Models\\Invoice;\n\n// Create an invoice object from an array or you can use constructor instead (new Invoice (...))\n$invoice = Invoice::createFromArray([\n    'profile' =\u003e Profile::MINIMUM,\n    'number' =\u003e 'F-202400001',\n    'typeCode' =\u003e InvoiceTypeCode::COMMERCIAL_INVOICE,\n    'issueDate' =\u003e DateTime::createFromFormat('Y-m-d', '2024-12-02'),\n    'totalAmountWithoutVAT' =\u003e 80.00,\n    'totalVATAmount' =\u003e 20.00,\n    'totalAmountWithVAT' =\u003e 100.00,\n    'amountDueForPayment' =\u003e 22.25,\n    'buyer' =\u003e [\n        'name' =\u003e 'Buyer NAME',\n        'address' =\u003e [\n            'countryCode' =\u003e 'FR',\n        ],\n\n        // optional\n        'buyerReference' =\u003e 'BUYER-0001',\n        'legalRegistrationIdentifier' =\u003e 'BUYER-SIRET',\n        // Precise the legal registration scheme identifier if different from SIRET\n        'schemeIdentifier' =\u003e SchemeIdentifier::SIREN,\n    ],\n    'seller' =\u003e [\n        'name' =\u003e 'Seller NAME',\n        'vatIdentifier' =\u003e 'FR12345678901',\n        'address' =\u003e [\n            'countryCode' =\u003e 'FR',\n        ],\n\n        // optional\n        'legalRegistrationIdentifier' =\u003e 'SELLER-SIRET',\n    ],\n\n    // optional\n    'businessProcessType' =\u003e 'A2', // default A1\n    'purchaseOrderReference' =\u003e 'PO-202400005',\n    'currencyCode' =\u003e 'EUR', // default EUR\n    'vatCurrency' =\u003e 'USD', // default EUR\n]);\n\n$xml = $invoice-\u003etoXml();\n// Or\n$xml = Builder::build($invoice);\n```\n\n### Validate XML against XSD\nValidate Factur-X XML against XSD. The XML source can be either a PDF file path, an XML file path or an XML string.\n```php\nuse MahdiAbderraouf\\FacturX\\Enums\\Profile;\nuse MahdiAbderraouf\\FacturX\\Exceptions\\InvalidXmlException;\nuse MahdiAbderraouf\\FacturX\\Exceptions\\UnableToExtractXmlException;\nuse MahdiAbderraouf\\FacturX\\Validator;\n\n$profile = Profile::MINIMUM;\n\n// PDF path, XML path or XML string\n$source = '/path/to/invoice.pdf';\n\ntry {\n    Validator::validate(\n        $source,\n\n        // Validate against a specific profile, or auto-detect it from the XML.\n        Profile::EN16931,\n    );\n} catch (UnableToExtractXmlException $e) {\n    // Failed to extract XML from given PDF\n    $message = $e-\u003egetMessage();\n} catch (InvalidXmlException $e) {\n    // array of LibXMLError\n    $errors = $e-\u003egetErrors();\n}\n\n// Or simply check if its valid or not\n$isValid = Validator::isValid($source);\n```\n\n### Generate a Factur-X PDF\nUsing the static method `Generator::generate` you can embed an XML into a PDF file to generate a Factur-X file.\n\nTo ensure the integrity of every Factur-X file, the XML is validated before being embedded, so there is no need to validate it beforehand.\n\nPlease note about attachment relationship:\n- The only relationships that can be used for the XML file are `Data`, `Source` and `Alternative`.\n- In Germany the only relationship allowed is `Alternative`.\n- For profiles `minimum` and `basicwl` only the relationship `Data` is allowed.\n- It is not recommanded to use the relationship `UNSPECIFIED` when adding additional attachments.\n\nIf you are generating invoices in Germany, the profiles `minimum` and `basicwl` are not considered legally as an invoice since they don't contain enough information. Same rule will be applied in France in the future so you should be using at least the `basic` profile.\n```php\nuse MahdiAbderraouf\\FacturX\\Enums\\Profile;\nuse MahdiAbderraouf\\FacturX\\Exceptions\\InvalidXmlException;\nuse MahdiAbderraouf\\FacturX\\Generator;\n\n$profile = Profile::BASIC;\n$invoice = Invoice::createFromArray([...]);\n\ntry {\n    $pdfString = Generator::generate(\n        // path or PDF string\n        '/path/to/Invoice.pdf',\n        // Invoice, XML string or path\n        $invoice,\n\n        // optional\n        AttachmentRelationship::DATA, // default one\n        'outputPath.pdf',\n        Profile::BASIC, // validates against a specific profile\n        // add more attachments if needed\n        [\n            [\n                'file' =\u003e 'extra_file.txt',\n                // optional\n                'filename' =\u003e 'Extra file name', // Defaults to the given file name\n                'relationship' =\u003e AttachmentRelationship::SUPPLEMENT, // Defaults to AttachmentRelationship::UNSPECIFIED when not present\n                'description' =\u003e 'This is some extra file description',\n            ]\n        ]\n    );\n} catch (InvalidXmlException $e) {\n    $errors = $e-\u003egetErrors();\n}\n```\n\n### Parse Factur-X PDF\nParse a Factur-X PDF file, the parser will look by default for files `factur-x.xml` and `zugferd-invoice.xml`.\n\nPlease note that the filename `zugferd-invoice.xml` is not used since the version 2.3 of ZUGFeRD.\nYou can specify the files you want to search for\n```php\nuse MahdiAbderraouf\\FacturX\\Enums\\XmlFilename;\nuse MahdiAbderraouf\\FacturX\\Exceptions\\UnableToExtractXmlException;\nuse MahdiAbderraouf\\FacturX\\Parser;\n\n// PDF path\n$pdf = '/path/to/invoice.pdf';\n\ntry {\n    // this will look for 'factur-x.xml' or 'zugferd-invoice.xml' files inside the given PDF\n    $xml = Parser::getXml(\n        $pdf,\n        XmlFilename::FACTUR_X, // look only for 'factur-x.xml'\n    );\n} catch (UnableToExtractXmlException $e) {\n    // This probably means that the file is not Factur-X\n    $message = $e-\u003egetMessage();\n}\n```\n\n---\n\n## Bug reports\nCreate an issue using the bug report template.\n\n---\n\n## Contributions\nContributions are welcome, here are some guidelines:\n- Code must be PSR-12\n- Provide an explanation of the changes\n- Provide the reason for the changes\n- If needed, update the documentation and provide an example.\n\n---\n\n## Roadmap\n- Add support for generating `en16931` and `extended` profiles\n- Factur-X parsing: parse a Factur-X file to an `Invoice` object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdiabderraouf%2Ffacturx-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahdiabderraouf%2Ffacturx-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdiabderraouf%2Ffacturx-php/lists"}