- How do I install jeroendesloovere/vcard in a Laravel app?
- Install it with Composer using composer require jeroendesloovere/vcard. There is no service provider, facade, config file, or publishable assets, so nothing needs registering in config/app.php. Make sure ext-mbstring is enabled in your container and CI images, and add ext-fileinfo if you plan to handle uploaded .vcf files. The usual pattern is to bind your own thin wrapper class as a singleton in a service provider you own.
- Does jeroendesloovere/vcard support Laravel 10 and Laravel 11?
- The package is framework-agnostic rather than Laravel-specific, so it works with any current Laravel version as long as the PHP constraint in its composer.json matches your runtime. It targets modern PHP 7.4 and 8.x, which covers Laravel 9 through 11. Check the PHP requirement before upgrading and re-run your tests on each PHP minor bump, since older string handling can hit deprecations.
- How do I generate a .vcf file from an Eloquent model in Laravel?
- Map your model attributes onto the library's vCard object inside a dedicated builder or exporter class rather than in the controller. Then return a download response with a text/vcard content type and a .vcf filename, or attach the generated string to a mail notification. Keeping the mapping in one class means the vendor API never leaks into controllers, jobs, or Blade components.
- Is it safe to parse user-uploaded vCard files with this library?
- Treat it as a serializer and parser, not a validator, and do the hardening in your own layer. Enforce upload size limits, mime type and extension checks, per-record error handling, and a cap on how many contacts a single file may contain. The package will not enforce business rules about contact data, and malformed third-party cards should fail gracefully into your own error path.
- Which vCard versions does jeroendesloovere/vcard support, 3.0 or 4.0?
- It supports generating and parsing vCard 3.0 and 4.0. Coverage is partial and version-sensitive, so differences such as line folding, quoted-printable versus base64 encoding, charset handling, and PHOTO embedding can surface as edge cases. Before committing, confirm with the team which versions you must emit and consume and which target clients are in the acceptance criteria.
- Can I add multiple phone numbers, emails, and addresses to a vCard?
- Yes. The library supports multiple phone numbers, email addresses, postal addresses, and URLs on a single card by repeating the relevant properties. You can also add custom properties for fields the standard does not cover, such as internal CRM identifiers. Type and preference parameters are how clients decide which number or email to show first.
- How do I embed a photo or company logo in a generated vCard?
- The library supports embedded photos, typically base64-encoded inside the PHOTO property. Be aware of the payload cost: images inflate the .vcf size substantially, which matters for downloads, email attachments, and memory on bulk exports. Consider omitting photos or using small, compressed images unless the acceptance criteria explicitly require them.
- Is jeroendesloovere/vcard still maintained, and what are the alternatives?
- Maintenance signal is the main risk: it is a single-maintainer project with roughly 517 stars and a last release in September 2023. Low activity is tolerable for a stable format library, but you should pin the version, commit composer.lock, and document a fork procedure. If you need broader spec coverage and stronger maintenance, sabre/vobject is the usual alternative and is well worth wrapping behind the same interface.
- Do I need a service provider or config file to use this package in Laravel?
- No. There is no Laravel service provider, facade, config file, or published assets, because it is a standalone PHP utility. The recommended approach is to define your own VCardExporter and VCardParser interfaces with the package as the initial implementation, then bind them in a service provider you control. That keeps a future swap to another library down to a one-class change.
- How should I test vCard generation and export in Laravel?
- Unit test your own builder and adapter rather than the vendor internals, asserting on expected lines in the raw vCard output and on the mime type and filename of the download response. Use fixture files to cover round-trip scenarios such as parsing a card you generated and re-emitting it. Because the package offers no strict validation guarantees, also verify real output by importing it into Outlook, Google Contacts, and Apple Contacts before shipping.