bright/vcard

Generate vCard files for quick contact import.

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/bright/vcard

v1.0.1 2025-11-09 14:11 UTC

This package is auto-updated.

Last update: 2025-11-14 10:33:29 UTC


README

A lightweight PHP package for generating .vcf (vCard) files — compatible with most contact applications.

Includes convenient helpers for building vCards from models or plain data arrays.

⚙️ Requirements

  • PHP 8.1+

Installation

Install via Composer:

composer require bright/vcard

Quick Usage

Create a simple vCard

use Bright\VCard\VCard;

$vcard = VCard::make()
    ->addName('Doe', 'John')
    ->addEmail('john@example.com', 'WORK')
    ->addPhoneNumber('+1 555-1234', 'WORK')
    ->addCompany('Bright')
    ->addJobtitle('Developer')
    ->addAddress('', '', '123 Main St', 'New York', '', '10001', 'United States')
    ->addURL('https://linkedin.com/in/johndoe', 'LinkedIn')
    ->addNote('Software Developer at Bright')
    ->addFilename('John Doe');

$file = $vcard->getFilename() . '.vcf';
$vcard->save(); // Saves to disk

File Output

By default, .vcf files are saved in the current working directory.
You can change the save directory:

$vcard->setSavePath(__DIR__ . '/exports/');
$vcard->save();

Output response

use Bright\VCard\VCard;

$vcard = VCard::make()
    ->addName('Doe', 'John')
    ->addEmail('john@example.com', 'WORK')
    ->addPhoneNumber('+1 555-1234', 'WORK')
    ->addCompany('Bright')
    ->addFilename('John Doe');

// Build the VCard
$output = $vcard->buildVCard();

// Set appropriate headers
$headers = $vcard->getHeaders(true);

// Output headers manually (instead of Laravel's response helper)
foreach ($headers as $key => $value) {
    header("$key: $value");
}

// Send the VCard data as the response
http_response_code(200);
echo $output;
exit;

Testing

To run the test suite (powered by Pest):

composer install
./vendor/bin/pest

📝 License

MIT License © Bright