xefi / faker-php-locales-pt-pt
Faker extension to include pt_PT locale
v1.0.1
2026-11-18 10:24 UTC
Requires
- php: ^8.3
- psr/container: ^2.0
- xefi/faker-php: ^1.5.3
Requires (Dev)
- phpunit/phpunit: ^11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
European Portuguese (pt_PT) locale for Faker PHP.
Installation
composer require --dev xefi/faker-php-locales-pt-pt
The service provider is discovered automatically through Composer.
Usage
use Xefi\Faker\Faker; $faker = new Faker('pt_PT'); $faker->name(); $faker->fullAddress(); $faker->personalNif();
The package provides pt_PT variants of the address, colors, company, financial, person, phone and text
extensions. Generators without a pt_PT variant fall back to the default locale.
Locale-specific generators
| Method | Extension | Description |
|---|---|---|
personalNif() |
PersonExtension |
Personal NIF (starts with 1, 2 or 3) with a valid mod 11 check digit |
cartaoCidadao() |
PersonExtension |
Cartão de Cidadão document number, 00000000 0 ZZ0, with valid check digits |
nif() |
CompanyExtension |
Company NIF / NIPC (starts with 5, 6 or 9) with a valid mod 11 check digit |
vat() |
CompanyExtension |
VAT number, PT followed by the company NIF |
district() |
AddressExtension |
One of the 18 mainland districts |
postcode() |
AddressExtension |
Código postal in the 0000-000 format |
nib() |
FinancialExtension |
21-digit NIB with valid check digits |
iban() |
FinancialExtension |
Portuguese IBAN (PT50 followed by a valid NIB) |
Contributing
- Fork the repository and create a branch from
main. - Add or update an extension under
src/Extensions/and register it inFakerPtPtServiceProvider::boot(). - Add a test under
tests/Unit/. - Run the suite with
vendor/bin/phpunit(ordocker compose run php vendor/bin/phpunit). - Open a pull request against
main.
License
MIT