A framework-agnostic VCard 3.0/4.0 generator for PHP 8.2+.
- Modern PHP support
- Lightweight and fast
- Typed API
- Framework agnostic
- Standards-oriented (RFC 6350)
- All 50 IANA registered properties supported
- Zero external dependencies
composer require abduns/vcarduse Dunn\VCard\VCard;
$vcf = VCard::make()
->addName('Doe', 'John')
->addEmail('john@example.com', 'work')
->addPhoneNumber('+62-812-3456-7890', 'cell')
->addUrl('https://johndoe.com')
->build();
echo $vcf;Example output:
BEGIN:VCARD
VERSION:4.0
N:Doe;John;;;
FN:John Doe
EMAIL;TYPE=work:john@example.com
TEL;TYPE=cell:+62-812-3456-7890
URL;TYPE=work:https://johndoe.com
REV:20240101T000000Z
END:VCARD- Existing solutions are outdated
- Missing modern PHP features
- Poor developer experience
- No standards compliance
- Too framework-coupled
This package focuses on simplicity, interoperability, and modern developer ergonomics. Most existing PHP vCard libraries use outdated binary encoding instead of data: URIs and aren't aligned with RFC 6350.
use Dunn\VCard\VCard;
VCard::make()->addName(
lastName: 'Doe',
firstName: 'John',
additional: '',
prefix: 'Dr.',
suffix: 'Jr.'
)
->addEmail('john@example.com', 'work')
->addPhoneNumber('+62-812-3456-7890', 'cell');// Embedded (raw base64 → automatically wrapped as data: URI)
->addPhoto($base64String, 'image/jpeg')
// Social Profiles
->addSocialProfile('https://github.com/johndoe', 'GitHub')
// UID (recommended for sync)
->addUid('urn:uuid:' . $uuid)
// Custom Properties
->addProperty('X-CUSTOM-FIELD', 'value')// The only enforced requirement at runtime is FN (Formatted Name).
// OK — addName() sets FN automatically
VCard::make()->addName('Doe', 'John')->build();Designed around official Internet standards and IANA registries.
- RFC 6350 (vCard 4.0)
- RFC 6474 (Birth/Death)
- RFC 6715 (Expertise/Hobby)
- RFC 8605 (CONTACT-URI)
- RFC 9554
- RFC 9555
References:
| Feature | Support |
|---|---|
| RFC 6350 Validation | ✅ |
| All IANA Properties | ✅ |
| Custom Properties | ✅ |
| Platform | Supported |
|---|---|
| PHP 8.2+ | ✅ |
| Apple Contacts | ✅ |
| Google Contacts | ✅ |
- Developer experience first
- Predictable APIs
- Minimal dependencies
- Strong typing
- Extensibility
- Interoperability
- immutable objects
- fluent builder pattern
- strong typing on inputs
| Operation | Time |
|---|---|
| Build typical vCard | < 1ms |
composer test- Validation API
- vCard parsing / reading
- jCard (JSON) support
- xCard (XML) support
Contributions, issues, and discussions are welcome.
If you discover security issues, please report them responsibly.
MIT