PHP code example of developerabod / laravel-contact-exporter
1. Go to this page and download the library: Download developerabod/laravel-contact-exporter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
developerabod / laravel-contact-exporter example snippets
return [
'table' => 'users', // Your database table name
'columns' => [
'first_name' => 'first_name', // The column name in your table
'last_name' => null, // null = disabled by default
'middle_name' => null,
'phone_mobile' => 'phone', // Primary mobile number — ted file (e.g. contacts.csv)
'append_count' => true, // If true: appends total contact count to filename, Example:contacts_250.vcf
'append_date' => false, // If true: appends export date to filename Example: contacts_2026-02-22.vcf
'skip_empty_phone' => true,
'normalize_phone' => true,
'charset_utf8' => true, // Enables UTF-8 encoding to support arabic
'chunk_size' => 500, // Chunk size for optimized processing
];
use VCard;
public function export()
{
return VCard::download();
// Output: contacts_250.vcf
}
return VCard::withLastName()->download();
return VCard::withEmail()->download();
return VCard::withLastName()->withEmail()->download();
return VCard::from('users')->download();
return VCard::map([
'first_name' => 'name',
'phone_mobile' => 'mobile_number',
])->download();
return VCard::where(['active' => 1])->download();
// Multiple conditions
return VCard::where(['active' => 1, 'country' => 'SA'])->download();
// All records
return VCard::fromQuery(Contact::query())->download();
// Using an existing scope on the model
return VCard::fromQuery(Contact::active())->download();
// With custom constraints
return VCard::fromQuery(
Contact::where('country', 'SA')->orderBy('first_name')
)->download();
return VCard::fromQuery(
DB::table('contacts')->where('active', 1)
)->download();
return VCard::download('company_employees');
// Output: company_employees_150.vcf
return VCard::fromQuery(Contact::active())
->map([
'first_name' => 'fname',
'last_name' => 'lname',
'phone_mobile' => 'mobile',
'phone_work' => 'work_phone',
'email' => 'email',
])
->withLastName()
->withEmail()
->filename('contacts_export')
->chunkSize(1000)
->download();
bash
php artisan vendor:publish --tag=vcard-exporter-config