PHPackages                             beastbytes/vcard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. beastbytes/vcard

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

beastbytes/vcard
================

Create and parse vCards

v1.0.0(3y ago)09BSD-3-ClausePHPPHP ^8.0

Since Jun 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/beastbytes/vcard)[ Packagist](https://packagist.org/packages/beastbytes/vcard)[ RSS](/packages/beastbytes-vcard/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

vCard
=====

[](#vcard)

The vCard library provides the ability to create [vCard (RFC 6350)](https://datatracker.ietf.org/doc/html/rfc6350) strings.

Creating vCard files
--------------------

[](#creating-vcard-files)

The vCard library allows creation of vCards in an object-oriented way.

The library provides class constants to provide code completion and improve code readability.

To create a vCard, create a new Vcard object then add properties to it; multiple properties with the same name are supported.

Properties that comprise multiple fields delimited by a SEMICOLON character (e.g., N and ADR) can be specified as array; empty fields **must** be given. If a property field is a list it may be specified as an array.

The following are equivalent:

```
->addProperty(
    Vcard::PROPERTY_N,
    'Perreault;Simon;;;ing. jr,M.Sc.'
)
```

```
->addProperty(
    Vcard::PROPERTY_N,
    [
        'Perreault',
        'Simon',
        '',
        '',
        'ing. jr,M.Sc.'
    ]
)
```

Provide property parameters as an array where the key is the parameter name (hint: use class constants) and the value is the value; if the value is a list it may be specified as an array.

The following are equivalent:

```
[
    Vcard::PARAMETER_VALUE => Vcard::VALUE_DATA_TYPE_URI,
    Vcard::PARAMETER_TYPE => '"' . Vcard::TYPE_WORK . ',' . Vcard::TYPE_VOICE . '"',
    Vcard::PARAMETER_PREF => 1
]
```

```
[
    Vcard::PARAMETER_VALUE => Vcard::VALUE_DATA_TYPE_URI,
    Vcard::PARAMETER_TYPE => [
        Vcard::TYPE_WORK,
        Vcard::TYPE_VOICE
    ],
    Vcard::PARAMETER_PREF => 1
]
```

Finally, call the Vcard's render() method.

### Note

[](#note)

The library does **not** do any checking for validity; it is possible to create a string that is not a valid vCard.

### Example

[](#example)

The following example creates the vCard at [section 8 of RFC6350](https://datatracker.ietf.org/doc/html/rfc6350#section-8).

```
$vCard = (new Vcard())
    ->addProperty(
        Vcard::PROPERTY_FN,
        'Simon Perreault'
    )
    ->addProperty(
        Vcard::PROPERTY_N,
        [
            'Perreault',
            'Simon',
            '',
            '',
            'ing. jr,M.Sc.'
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_BDAY,
        '--0203'
    )
    ->addProperty(
        Vcard::PROPERTY_ANNIVERSARY,
        '20090808T1430-0500'
    )
    ->addProperty(
        Vcard::PROPERTY_GENDER,
        Vcard::GENDER_MALE
    )
    ->addProperty(
        Vcard::PROPERTY_LANG,
        'fr',
        [
            Vcard::PARAMETER_PREF => 1
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_LANG,
        'en',
        [
            Vcard::PARAMETER_PREF => 2
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_ORG,
        'Viagenie',
        [
            Vcard::PARAMETER_TYPE => Vcard::TYPE_WORK
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_ADR,
        [
            '',
            'Suite D2-630',
            '2875 Laurier',
            'Quebec',
            'QC',
            'G1V 2M2',
            'Canada'
        ],
        [
            Vcard::PARAMETER_TYPE => Vcard::TYPE_WORK
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_TEL,
        'tel:+1-418-656-9254;ext=102',
        [
            Vcard::PARAMETER_VALUE => Vcard::VALUE_DATA_TYPE_URI,
            Vcard::PARAMETER_TYPE => [
                Vcard::TYPE_WORK,
                Vcard::TYPE_VOICE
            ],
            Vcard::PARAMETER_PREF => 1
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_TEL,
        'tel:+1-418-262-6501',
        [
            Vcard::PARAMETER_VALUE => Vcard::VALUE_DATA_TYPE_URI,
            Vcard::PARAMETER_TYPE => [
                Vcard::TYPE_WORK,
                Vcard::TYPE_CELL,
                Vcard::TYPE_VOICE,
                Vcard::TYPE_VIDEO,
                Vcard::TYPE_TEXT
            ],
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_EMAIL,
        'simon.perreault@viagenie.ca',
        [Vcard::PARAMETER_TYPE => Vcard::TYPE_WORK]
    )
    ->addProperty(
        Vcard::PROPERTY_GEO,
        'geo:46.772673,-71.282945',
        [
            Vcard::PARAMETER_TYPE => Vcard::TYPE_WORK
        ]
    )
    ->addProperty(
        Vcard::PROPERTY_KEY,
        'http://www.viagenie.ca/simon.perreault/simon.asc',
        [
            Vcard::PARAMETER_TYPE => Vcard::TYPE_WORK,
            Vcard::PARAMETER_VALUE => Vcard::VALUE_DATA_TYPE_URI
        ]
    )
    ->addProperty(Vcard::PROPERTY_TZ, '-0500')
    ->addProperty(
        Vcard::PROPERTY_URL,
        'http://nomis80.org',
        [
            Vcard::PARAMETER_TYPE => Vcard::TYPE_HOME
        ]
    )
    ->render()
;
```

Import vCard
------------

[](#import-vcard)

Import an vCard file using Vcard's static import() method:

```
$vcard = Vcard::import($string);
```

Installation
------------

[](#installation)

The preferred way to install the library is with [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist beastbytes/icalendar

```

or add

```
"beastbytes/vcard": "^1.0.0"
```

to the 'require' section of your composer.json.

Testing
-------

[](#testing)

### Unit testing

[](#unit-testing)

The package is tested with PHPUnit. To run the tests:

```
./vendor/bin/phpunit

```

### Static analysis

[](#static-analysis)

The code is statically analyzed with Psalm. To run static analysis:

```
./vendor/bin/psalm

```

License
-------

[](#license)

The vCard Library is free software. It is released under the terms of the BSD License. For license information see the [LICENSE](LICENSE.md) file.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0b5133b5137b26eeb25056449c28364ac0af31836eefba78912a9c8f0743aa3?d=identicon)[BeastBytes](/maintainers/BeastBytes)

---

Top Contributors

[![beastbytes](https://avatars.githubusercontent.com/u/1470144?v=4)](https://github.com/beastbytes "beastbytes (3 commits)")

---

Tags

vCardRFC 6350

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/beastbytes-vcard/health.svg)

```
[![Health](https://phpackages.com/badges/beastbytes-vcard/health.svg)](https://phpackages.com/packages/beastbytes-vcard)
```

###  Alternatives

[sabre/vobject

The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

59725.3M55](/packages/sabre-vobject)[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[protonlabs/vobject

The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

1154.5k](/packages/protonlabs-vobject)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
