PHP developer in Lisbon

WordPress for businesses in Lisbon, delivered remotely by one developer.

PHP developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.
  • Local WordPress meetup: WordPress Lisboa

My WordPress.org profile

A PHP application that issues invoices in Portugal is not only an application. Portuguese rules treat it as a system that must make tampering visible, number documents in series, print codes and export a standard file. I am Mariusz Szatkowski, a PHP developer in Gdynia, and I work with Lisbon clients by email and shared documents. Whether your company needs certified software is a decision for you and your accountant. I build the module so its data model meets the technical texts, and this page shows which texts those are.

Vasco da Gama Tower rising over Parque das Nações in Lisbon

Parque das Nações with the Vasco da Gama Tower, photographed by Haydn Blackey (Cardiff) and shared under CC BY-SA 2.0 on Wikimedia Commons.

#When must invoicing software be certified?

Decree-Law 28/2019 of 15 February consolidates the invoicing rules for VAT taxpayers. Article 3 says invoices and other tax-relevant documents are processed by one of three means: invoicing programs (including the application the Autoridade Tributária e Aduaneira, AT, makes available), other electronic means such as cash registers and terminals, or pre-printed documents from an authorised printer.

Article 4 then obliges taxpayers with a seat, permanent establishment or domicile in Portugal to use only programs previously certified by the AT, when the conditions listed in that article apply. They include a turnover test for the previous calendar year and the use of invoicing software. I leave the exact test to your adviser, because the article can be amended. The AT portal shows the decree-law as in force, amended by Decree-Law 48/2020 and Decree-Law 49/2025.

The AT keeps a list of certified programs and versions on its website, with the producers named (article 4(3)). The certificate belongs to a program version. Article 5(5) of Portaria 363/2010 adds that a certified version must keep meeting the requirements even when a taxpayer who is not obliged to use certified software runs it.

#What does Portaria 363/2010 ask of the software?

The Portaria of 23 June 2010 regulates the prior certification of invoicing programs. Its preamble gives the reason: electronic processing speeds up work but allows later alteration of recorded data, so only programs that guarantee the inviolability of the first record may be used. The AT portal lists it as in force and names these amendments: Portaria 22-A/2012, Portaria 160/2013, Portaria 340/2013 (which republished it) and Decree-Law 28/2019, which revoked articles 1, 2, 8 and 9.

Article 3 sets five cumulative requirements for certification:

  • the program can export the file defined in Portaria 321-A/2007, the SAF-T (PT)
  • a system identifies the recording of invoices and rectifying documents with an asymmetric cipher and a private key known only to the program producer
  • access control forces authentication of every user
  • no function, locally or remotely, changes tax information directly or indirectly without generating evidence attached to the original information
  • the other technical requirements approved by an order of the AT director-general are met

The last item points to technical documents I did not read for this page. Anyone building to certification works from them as well.

#How does the signature chain work?

Article 6 names the algorithm: RSA. The message to sign is built from five values of the sales document, joined in this order with a semicolon:

  1. the document date (InvoiceDate in the SAF-T)
  2. the date and time of recording (SystemEntryDate)
  3. the document number (InvoiceNo)
  4. the total with taxes (GrossTotal)
  5. the signature of the previous document of the same type and series (Hash)

The resulting signature and the version of the private key must be kept in the program’s database. Article 7 applies the same mechanism to transport documents and to working documents handed to a customer to check delivery, with their own field lists.

In PHP the signing step is one call. The openssl_sign manual documents it as openssl_sign(string $data, string &$signature, $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1), returning a boolean. The Portaria names RSA and not a digest, so the digest below is a parameter that comes from the AT’s technical documentation.

<?php
declare(strict_types=1);

function signInvoice(
    string $invoiceDate,      // 2026-12-04
    string $systemEntryDate,  // 2026-12-04T10:15:00
    string $invoiceNo,        // FT 2026A/12
    string $grossTotal,       // format per the AT technical notes
    string $previousHash,     // empty rule for a first document: AT notes
    \OpenSSLAsymmetricKey $privateKey,
    string|int $digest,
): string {
    $message = implode(';', [$invoiceDate, $systemEntryDate, $invoiceNo, $grossTotal, $previousHash]);
    if (!openssl_sign($message, $signature, $privateKey, $digest)) {
        throw new \RuntimeException('Signing failed');
    }
    return base64_encode($signature);
}

Two storage decisions follow from the text. The stored signature is never recomputed on read, and the key version sits in the same row as the signature, so a later key rotation does not orphan old documents.

#What must be printed on the document?

Article 6(3) of the Portaria lists what a signed document carries:

  • four characters of the signature, the 1st, 11th, 21st and 31st positions, separated by hyphens
  • the phrase “Processado por programa certificado n.º” followed by the certificate number of the program
  • the unique identification of the document

With zero-based string offsets, as substr counts them according to the php.net manual, those positions are 0, 10, 20 and 30. An off-by-one error here is easy to ship, so I keep it in a single tested function. The same four characters feed field Q of the QR code, and the certificate number feeds field R, according to the AT’s QR specification.

#How are series and the ATCUD built?

Article 7(4) of Decree-Law 28/2019 requires invoices and tax-relevant documents to be issued in one or more series, dated and numbered progressively and continuously within each series, for a period of not less than one fiscal year. Article 35 adds that taxpayers communicate each series electronically to the AT before using it, and that the AT assigns a code which becomes part of the unique document code.

Portaria 195/2020 of 13 August sets the details. For each series, the taxpayer communicates:

ElementSource in the Portaria
Series identifierarticle 2(a)
Document type, per the SAF-T typesarticle 2(b)
Start of the sequential numberingarticle 2(c)
Expected first date of usearticle 2(d)

The AT returns a validation code of at least eight characters. The ATCUD is that code, a hyphen and the sequence number, which in invoicing programs is the digit string right after the slash in the document’s unique identification. The mandatory print format is ATCUD:CodigodeValidação-NumeroSequencial, on every invoice and tax-relevant document from any processing means. On a multi-page document it appears on every page.

For the data model this means a series table with the validation code, the document type, the next number and a flag that the code has been obtained. A document cannot be finalised while its series lacks a code. The text of the Portaria gives the entry into force as 1 January 2021, with a transitional communication window in December 2020. I did not confirm from a primary source the date from which the AT enforces the ATCUD in practice, so check the current AT notices.

#What does the AT QR code contain?

Article 6 of the Portaria requires the QR code on documents issued by programs certified by the AT. The technical content comes from the AT’s specification, version 1.1 of October 2020, which sets:

  • error correction level M, byte mode, version 9 as a minimum, image at least 30 by 30 mm, margin 0.25 cm
  • fields written as a code, a colon and the value, joined by an asterisk, in the order of the specification
  • amounts in euros with a dot and two decimals, converted beforehand for documents in other currencies
  • field A for the issuer’s tax number, B for the customer’s (999999990 for a final consumer), H for the ATCUD, Q for the four signature characters, R for the certificate number

Each field is marked mandatory or optional in the table, and optional fields without data are left out. A PHP module should build the string from the same records that feed the SAF-T export, so the QR and the file cannot disagree. Rendering the image is a library choice. What matters is the checks: a unit test that parses the string back into fields, and a test per document type from the examples in the specification.

#What about SAF-T (PT) and communication to the AT?

The first requirement of article 3 is the export of the SAF-T (PT) file. The structure was set by Portaria 321-A/2007 and changed by Portaria 302/2016 of 2 December, which the AT portal lists as in force. Decree-Law 28/2019 also amends article 3 of Decree-Law 198/2012. As worded on the AT portal, taxpayers communicate invoice data either by real-time transmission or by sending a standard file based on the SAF-T (PT), no later than the 10th day of the month after issue.

A custom module therefore keeps its tax records in a shape that exports without transformation guesses: one row per document line with the tax code and rate, document status, and the dates in the form the SAF-T expects. I do not repeat the full schema here. The AT publishes it and the file should be validated against it in the test pipeline.

#Checklist for a Portuguese invoicing module

  • Decide with your accountant whether article 4 of Decree-Law 28/2019 applies to you.
  • Keep signature, key version and previous-signature link in the database, never recomputed on read.
  • Block edits to finalised documents, and record every correction as a new rectifying document.
  • Store series codes from the AT and refuse to finalise documents in a series without one.
  • Print the ATCUD on every page and the QR code on the first or last page.
  • Test the four-character extract at offsets 0, 10, 20 and 30.
  • Validate the SAF-T export against the AT schema on every release.

#How does a project run?

  1. You send the current invoicing setup, the document types you issue and your accountant’s name.
  2. I write down the scope, the assumptions and the questions for the accountant, in writing.
  3. I build on a staging copy with test series and test keys, and you check sample documents and the export.
  4. After your written acceptance, the module goes live. Production keys stay with you.

I need access to the repository or the current system, and the technical notes you already hold from the AT. The wider scope of custom PHP work is described on the PHP developer page.

#Planning an invoicing module in Lisbon?

Describe the documents you issue and the system you issue them from through the contact form. The first written estimate is free, and it comes with the questions I would put to your accountant before any code is written. I am not a lawyer, and the legal reading stays with you and your adviser.

See also in Portugal

Need this service: PHP developer in Lisbon?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Latest PHP developer articles

Dec 2, 2026

Laravel Rust: what does it mean for PHP apps?

On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.

Explore other WordPress services and knowledge base