r/PHP • u/Worried_Librarian_79 • 17h ago
Standard identifiers for PHP
https://php-stdnum.org/I've released php-stdnum, an MIT-licensed PHP library for working with standardized identifiers.
The initial release includes:
606 validators covering VAT numbers, tax identifiers, IBANs, national identifiers, company registration numbers, ISBNs, postal codes and more.
594 native deterministic test-data generators.
Validation, normalization, formatting and scoped detection.
Immutable value objects and typed validation errors.
Optional Laravel, Symfony, Doctrine and FakerPHP integrations.
PHP 8.3–8.6 compatibility.
Documentation: https://php-stdnum.org/
GitHub: https://github.com/php-stdnum/php-stdnum
I'd appreciate technical feedback. Thank you!
3
u/Vectorial1024 16h ago
Why should I use this library when eg I only need the IBAN validation?
3
u/Worried_Librarian_79 15h ago
If you only need IBAN, a dedicated library may be a better choice.
The main benefit of php-stdnum is when an application needs to handle multiple types of identifiers:
- an ERP may need IBAN, VAT, tax identifiers and company registration numbers
- a HR or payroll application may need to validate personal identifiers from multiple countries
- e-commerce may need VAT, postal codes, GTINs and ISBNs.
It won't be the best choice for every use case, but I think it makes sense for applications dealing with multiple standardized identifiers.
2
u/titpetric 15h ago
Idk why would i care, wouldnt it load just what it needs? I am checking your lib out mostly to run the test suite.
If i am being paranoid i could prune the vendor folder to just what I use with automation, assuming SRP is followed
1
u/Worried_Librarian_79 15h ago
When using an identifier class directly, only that class and its required dependencies are loaded, not all 606 validators. The core has no third-party runtime dependencies.
Since you mentioned running the tests, if you have the time, I'd be interested in your feedback. Thank you!
2
u/Vectorial1024 15h ago
Let me be real with you. The probability of "I will need everything here" is extremely low. If you can't convince people to stop using their existing vendors, then this pet project of yours is just digital scrap and has no practical value.
3
u/HumbleCan6392 10h ago
I would rather use a specific library for my usecase like https://github.com/Fale/isbn instead of some vibecoded
1
u/Worried_Librarian_79 9h ago
I was curious about the comparison, so I tested fale/isbn 3.1.0 and php-stdnum 0.1.0.
I respect the work that went into fale/isbn, which has over 500,000 installs. However, there are correctness issues:
- It accepts 9520123456788, a non-book GTIN, as a valid ISBN-13 (https://ref.gs1.org/standards/digital-link/uri-syntax/1.7.0/#gtin)
- It accepts 9790345246805, which is an ISMN, not an ISBN (https://ismn-international.org/ismn/ranges/)
- It converts 9798891790612 to ISBN-10, although the International ISBN Agency explicitly states that ISBNs starting with 979 have no ISBN-10 equivalent (https://www.isbn-international.org/content/changes-united-states-isbn-prefixes)
Thanks for suggesting the comparison.
0
26
u/goodwill764 16h ago •
I love project that just dump code (1 commit, +3.571.031 lines) , already have a full website and a .org domain.
User profile ( https://github.com/g-marinescu ) : Creator and Maintainer of php-stdnum
How can you be a maintainer without a git history?
"think big"