rumenx/drupal_vcard

This package is abandoned and no longer maintained. The author suggests using the drupal/vcard_generator package instead.

Drupal 11+ module to generate vCards.

v1.0.0-beta 2025-06-10 09:47 UTC

This package is auto-updated.

Last update: 2025-06-12 17:56:08 UTC


README

CI codecov

Features

  • Provides a service for generating vCards in Drupal.
  • 100% PHPUnit unit test coverage.
  • Composer-managed dependencies.

Installation

Composer (Packagist)

composer require rumenx/drupal_vcard_generator

Enable the module in Drupal admin or via Drush:

drush en drupal_vcard_generator

Manual Installation (GitHub/Packagist)

  1. Download or clone this repository:

    • Download the ZIP from GitHub and extract it, or run:

      git clone https://github.com/RumenDamyanov/drupal_vcard_generator.git
  2. Copy the drupal_vcard_generator folder into your Drupal site's modules/custom/ directory.

  3. Enable the module in Drupal admin or via Drush:

    drush en drupal_vcard_generator

Drupal.org Installation (Recommended)

You can install the module from Drupal.org either manually or using Composer:

Option 1: Composer (Recommended)

composer require drupal/vcard_generator

Enable the module in Drupal admin or via Drush:

drush en vcard_generator

Option 2: Manual Installation

  1. Download from Drupal.org:
  2. Copy the vcard_generator folder into your Drupal site's modules/custom/ directory.
  3. Enable the module:
    drush en vcard_generator

Usage Example

/** @var \Drupal\drupal_vcard_generator\VCardGenerator $generator */
$generator = \Drupal::service('drupal_vcard_generator.generator');
$vcard = $generator->createVCard([
  'first_name' => 'Jon',
  'last_name' => 'Snow',
  'email' => 'jon.snow@winterfell.localhost',
]);
echo $vcard;

Advanced Usage Example

/** @var \Drupal\drupal_vcard_generator\VCardGenerator $generator */
$generator = \Drupal::service('drupal_vcard_generator.generator');
$vcard = $generator->createVCard([
  'first_name' => 'Thomas A.',
  'last_name' => 'Anderson',
  'email' => 'neo@thematrix.localhost',
  'phone' => '+1-800-NEO-0001',
  'address' => [
    'street' => '303 Matrix Lane',
    'city' => 'Mega City',
    'state' => 'Zion',
    'zip' => '10101',
    'country' => 'Simulated Reality',
  ],
  'organization' => 'Resistance',
  'department' => 'The One',
  'title' => 'The One',
  'url' => 'https://thematrix.localhost/neo',
]);
file_put_contents('neo.vcf', $vcard);

Supported Fields

  • first_name, last_name: Person's name
  • email: Email address
  • phone: Phone number
  • address: Array with street, city, state, zip, country
  • organization: Organization name
  • department: Department/unit (optional)
  • title: Job title
  • url: Website

Example Output

BEGIN:VCARD
VERSION:3.0
N:Anderson;Thomas A.
FN:Thomas A. Anderson
EMAIL:neo@thematrix.localhost
TEL:+1-800-NEO-0001
ADR:;;303 Matrix Lane;Mega City;Zion;10101;Simulated Reality
ORG:Resistance;The One
TITLE:The One
URL:https://thematrix.localhost/neo
END:VCARD

Testing

Run lint and unit tests with:

composer lint
composer test

License

MIT. See LICENSE.md.