---
title: "vCard export — Contacts for Laravel | Roundly"
description: "Export an owner’s contacts or a single contact as a valid vCard 3.0 card that Apple, Google and other address books read."
url: https://roundly-consulting.com/open-source/docs/contacts-for-laravel/vcard
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Contacts for Laravel](https://roundly-consulting.com/open-source/docs/contacts-for-laravel.md)

# vCard export

```php
use RoundlyConsulting\Contacts\Facades\Contacts;

$user = User::create(['name' => 'Jane Doe']);
$user->addEmail('jane@example.com', label: 'Work');
$user->addPhone('+421 900 000 000', label: 'Mobile');
$user->addUrl('example.com', label: 'Office, main');

Contacts::for($user)->vCard();   // a vCard 3.0 string for the owner's contacts
$contact->toVCard();             // a single contact
```

The owner above exports as:

```
BEGIN:VCARD
VERSION:3.0
N:Jane Doe;;;;
FN:Jane Doe
EMAIL;TYPE=work:jane@example.com
TEL;TYPE=cell:+421900000000
item1.URL:https://example.com
item1.X-ABLabel:Office\, main
END:VCARD
```

The card is valid vCard 3.0 (RFC 2426), with CRLF line endings:

- N and FN are always present. N is built from the owner’s structured name attributes when it has them — last\_name/family\_name/surname, first\_name/given\_name, middle\_name/additional\_name, name\_prefix/honorific\_prefix, name\_suffix/honorific\_suffix. Otherwise the display name fills N’s family-name slot (N:Jane Doe;;;;).
- FN is the owner’s name, else the structured parts joined, else Contact. Only attributes the model actually has are read, so Model::shouldBeStrict() is safe.
- Email, phone, URL and address contacts map to EMAIL, TEL, URL and ADR; social and custom kinds are exported as NOTE.
- Labels: a label naming a registered type for its property (work, home, cell, fax, pager…; mobile becomes cell) is emitted as TYPE=work. Any other label is kept as itemN.X-ABLabel on a grouped property — the custom-label form Apple and Google contacts read.
- Text is escaped (backslash, comma, semicolon, and any line break as \\n), URLs are left unescaped, and long lines fold at 75 octets without splitting a UTF-8 character.

## Exporter and downloads

VCardExporter builds any set of contacts; a single contact’s toVCard() uses Contact as its name. Serve the string as a download from a controller:

```php
use RoundlyConsulting\Contacts\Support\VCardExporter;

VCardExporter::forOwner($user);                                     // same as Contacts::for($user)->vCard()
VCardExporter::forContacts($user->contactsOfType('email'), 'Jane Doe');  // any set, with a name

return response(Contacts::for($user)->vCard(), 200, [
    'Content-Type' => 'text/vcard',
    'Content-Disposition' => 'attachment; filename="jane-doe.vcf"',
]);
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/contacts-for-laravel.md)
