bright/vcard
最新稳定版本:v1.0.1
Composer 安装命令:
composer require bright/vcard
包简介
Generate vCard files for quick contact import.
README 文档
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
统计信息
- 总下载量: 98
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-09