rumenx / drupal_vcard
Drupal 11+ module to generate vCards.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 1
Type:drupal-module
Requires
- php: >=8.3
- drupal/core: ^11.0
- rumenx/php-vcard: ^1.0
Requires (Dev)
- drupal/coder: ^8.3
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-06-12 17:56:08 UTC
README
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)
-
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
-
-
Copy the
drupal_vcard_generator
folder into your Drupal site'smodules/custom/
directory. -
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
- Download from Drupal.org:
- https://www.drupal.org/project/vcard_generator
- Git:
git clone https://git.drupalcode.org/project/vcard_generator.git
- Copy the
vcard_generator
folder into your Drupal site'smodules/custom/
directory. - 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 nameemail
: Email addressphone
: Phone numberaddress
: Array withstreet
,city
,state
,zip
,country
organization
: Organization namedepartment
: Department/unit (optional)title
: Job titleurl
: 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.