VCard
PHP library to generate and parse vCard (.vcf) contact files
Repository Health
Technical Analysis
VCard is a PHP library for building and reading vCard files, the standard format for electronic contact cards. It provides a fluent API to assemble a contact from names, companies, job titles, phone numbers, emails, addresses, URLs, and photos, then output it as a string, save it, or serve it as a download.
The library handles device quirks, such as exporting an .ics file for older iOS versions that do not support .vcf, and includes a parser for reading vCard data back into structured objects. It is a lightweight, dependency-light package suitable for contact export features in any PHP application.
What You Get
- A fluent VCard builder covering names, companies, phones, emails, addresses, and URLs
- Photo embedding from local files or remote URLs
- Output as a string, saved file, or browser download response
- Automatic .ics fallback for older iOS devices that reject .vcf
- A VCardParser for reading vCard data back into structured values
Common Use Cases
- Adding a ‘download my contact card’ button to a website or profile page
- Exporting user or team contact details from a CRM or directory
- Generating vCards in bulk from a database of contacts
Under The Hood
Architecture - The library is intentionally tiny: src/VCard.php holds the builder that accumulates fields into internal properties and assembles the RFC-style vCard text via getOutput(), with save()/download() handling delivery and content-type headers; src/VCardParser.php reads vCard content back into structured values, and src/VCardException.php provides typed errors. Photo handling resolves local paths or remote URLs before embedding.
Tech Stack - Plain PHP distributed via Composer under the JeroenDesloovere\VCard namespace, with essentially no runtime dependencies. Dev tooling includes PHPUnit (phpunit.xml.dist) and historically Travis CI and Scrutinizer.
Code Quality - A tests/ suite with PHPUnit covers generation and parsing, and examples/ demonstrate real usage. The code is straightforward and readable; the project is mature but in low-activity maintenance, with a 4.0 rewrite explored on a branch.
API Design - The add* builder pattern reads almost like prose (addName, addEmail, addPhoneNumber, addPhoto) and the three output methods (getOutput/save/download) cover the common delivery paths, so getting a working contact card takes only a few lines with a shallow learning curve.