• Stars
    star
    498
  • Rank 88,494 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 11 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This vCard PHP library can easily parse or generate/export vCards as .vcf

VCard PHP library

Latest Stable Version License Build Status Scrutinizer Code Quality

This VCard PHP library can generate a vCard with some data. When using an iOS device < iOS 8 it will export as a .ics file because iOS devices don't support the default .vcf files.

NOTE: We are working on a complete new version to work with vCard version 4.0, with extreme good code quality. Check out the new version

Usage

Installation

composer require jeroendesloovere/vcard

This will install the latest version of vcard with Composer

Example

use JeroenDesloovere\VCard\VCard;

// define vcard
$vcard = new VCard();

// define variables
$lastname = 'Desloovere';
$firstname = 'Jeroen';
$additional = '';
$prefix = '';
$suffix = '';

// add personal data
$vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);

// add work data
$vcard->addCompany('Siesqo');
$vcard->addJobtitle('Web Developer');
$vcard->addRole('Data Protection Officer');
$vcard->addEmail('[email protected]');
$vcard->addPhoneNumber(1234121212, 'PREF;WORK');
$vcard->addPhoneNumber(123456789, 'WORK');
$vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
$vcard->addLabel('street, worktown, workpostcode Belgium');
$vcard->addURL('http://www.jeroendesloovere.be');

$vcard->addPhoto(__DIR__ . '/landscape.jpeg');

// return vcard as a string
//return $vcard->getOutput();

// return vcard as a download
return $vcard->download();

// save vcard on disk
//$vcard->setSavePath('/path/to/directory');
//$vcard->save();

View all examples or check the VCard class.

Parsing examples

The parser can either get passed a VCard string, like so:

// load VCardParser classes
use JeroenDesloovere\VCard\VCardParser;

$parser = new VCardParser($vcardString);
echo $parser->getCardAtIndex(0)->fullname; // Prints the full name.

Or by using a factory method with a file name:

$parser = VCardParser::parseFromFile('path/to/file.vcf');
echo $parser->getCardAtIndex(0)->fullname; // Prints the full name.

View the parsing example or check the the VCardParser class class.

Support for frameworks

I've created a Symfony Bundle: VCard Bundle

Usage in for example: Laravel

return Response::make(
    $this->vcard->getOutput(),
    200,
    $this->vcard->getHeaders(true)
);

Tests

vendor/bin/phpunit tests

Documentation

The class is well documented inline. If you use a decent IDE you'll see that each method is documented with PHPDoc.

Contributing

Contributions are welcome and will be fully credited.

Pull Requests

To add or update code

  • Coding Syntax - Please keep the code syntax consistent with the rest of the package.
  • Add unit tests! - Your patch won't be accepted if it doesn't have tests.
  • Document any change in behavior - Make sure the README and any other relevant documentation are kept up-to-date.
  • Consider our release cycle - We try to follow semver. Randomly breaking public APIs is not an option.
  • Create topic branches - Don't ask us to pull from your master branch.
  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.
  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Issues

For bug reporting or code discussions.

More info on how to work with GitHub on help.github.com.

Credits

License

The module is licensed under MIT. In short, this license allows you to do everything as long as the copyright statement stays present.

More Repositories

1

geolocation-php-api

This Geolocation PHP class connects to Google Geocoding API to find latitude/longitude or the address.
PHP
73
star
2

distance

This Distance PHP class can calculate the distance between two latitude/longitude locations using Math functions in PHP. No external API's are called.
PHP
35
star
3

wunderlist-php-api

This Wunderlist PHP Class connects to the Wunderlist API and has all functions implemented to insert/update/delete lists, tasks, reminders, files, notes, ...
PHP
17
star
4

vcard-bundle

A Symfony2 bundle for creating vCards.
PHP
16
star
5

examples-windows

Examples for programming windows apps.
C++
10
star
6

xmp-metadata-extractor

Extracting XMP metadata from images/files using PHP.
PHP
8
star
7

cache

This Cache PHP class allows you to cache pages and data.
PHP
7
star
8

geolocation-bundle

This Geolocation Symony2 Bundle uses the geolocation-php-api class using Google Maps API which finds latitude/longitude from an address or reverse.
PHP
5
star
9

add-text-to-images

This AddTextToImages PHP class adds text to images using PHP.
PHP
3
star
10

volleyadmin2-php-api

This PHP class can get the volleybal matches/calendar from "volleyadmin2".
PHP
3
star
11

linkedin-php-api

[WIP] This LinkedIn PHP API wrapper connects to LinkedIn API v1.
PHP
3
star
12

swamicms

[Discontinued] Swami CMS is a small cms I (Jeroen Desloovere) made, based on the dingo framework. Stopped working on this because I'm using Fork CMS instead.
PHP
3
star
13

safari-local-notifications-api

This jQuery Safari Local Notifications class can send local notifications to the visitors of your website.
JavaScript
3
star
14

yelp-php-api

This Yelp PHP API can search for businesses.
PHP
2
star
15

showpad-php-api

This PHP class connects to the Showpad API.
PHP
2
star
16

camera-api

This jQuery Camera API uses the device camera.
JavaScript
2
star
17

forkcms-tools

Tools for developers
2
star
18

convert-flash-html-text

This ConvertText PHP class allows you to convert between Flash/Flex htmlText and html.
PHP
2
star
19

fullscreen-api

This jQuery Fullscreen API allows you to set your website fullscreen.
JavaScript
1
star
20

css-html-snippet-library

Collection of front-end snippets
CSS
1
star
21

character-collection

The character converter
PHP
1
star
22

sitemap

PHP
1
star
23

twitter-worker

Twitter worker
HTML
1
star
24

image-meta-data

This ImageMetaData PHP class can get/set Meta data to images.
PHP
1
star
25

web-components

[Testing] Web components are amazing.
HTML
1
star
26

opauth-mailchimp

[WIP] Mailchimp authentication strategy for Opauth.
1
star
27

jeroendesloovere.github.io

Webpage of Jeroen Desloovere
HTML
1
star
28

countries-php-api

This Countries PHP class gets all the countries in the world and their information using an API.
PHP
1
star
29

sitemap-bundle

This Symfony bundle allows you to easily generate a sitemapindex and one or multiple sitemap(s).
PHP
1
star
30

package-skeleton-bundle

This Symfony 2 bundle is a skeleton used for fast bundle generating to load in a class as a service.
PHP
1
star
31

visibility-api

This jQuery Page Visibility API allows you to check the websites browser tab visibility state.
JavaScript
1
star
32

fork-cms-module-formbuilder-upload-field

PHP
1
star
33

add-watermark-to-image

This AddWatermarkToImage PHP class can add watermarks to an image using PHP.
PHP
1
star
34

command-handlers

Command Handlers explained
1
star
35

cypress-example-symfony-world

Example test from the live coding session "Symfony meets Cypress - E2E testing for symfony developers"
JavaScript
1
star
36

package-skeleton

Skeleton for a PHP Package.
PHP
1
star
37

swami-as3-mvc

[NOT WORKING] Swami is an AS 3.0 MVC which connects to Fork CMS.
ActionScript
1
star
38

web-worker

Web worker
HTML
1
star
39

vapor-test

[Test] My first website in Swift, using the Vapor Swift Web Framework
Swift
1
star
40

battery-api

This jQuery Battery API allows you to check battery level and if the battery is charging or not
JavaScript
1
star