example.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * VCard generator test - can save to file or output as a download
  4. */
  5. require_once __DIR__ . '/../vendor/autoload.php';
  6. require_once __DIR__ . '/../src/VCard.php';
  7. use JeroenDesloovere\VCard\VCard;
  8. // define vcard
  9. $vcard = new VCard();
  10. // define variables
  11. $firstname = 'Jeroen';
  12. $lastname = 'Desloovere';
  13. $additional = '';
  14. $prefix = '';
  15. $suffix = '';
  16. // add personal data
  17. $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);
  18. // add work data
  19. $vcard->addCompany('Siesqo');
  20. $vcard->addJobtitle('Web Developer');
  21. $vcard->addEmail('info@jeroendesloovere.be');
  22. $vcard->addPhoneNumber(1234121212, 'PREF;WORK');
  23. $vcard->addPhoneNumber(123456789, 'WORK');
  24. $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
  25. $vcard->addURL('http://www.jeroendesloovere.be');
  26. $vcard->addPhoto(__DIR__ . '/assets/landscape.jpeg');
  27. //$vcard->addPhoto('https://raw.githubusercontent.com/jeroendesloovere/vcard/master/tests/image.jpg');
  28. // return vcard as a string
  29. //return $vcard->getOutput();
  30. // return vcard as a download
  31. return $vcard->download();
  32. // echo message
  33. echo 'A personal vCard is saved in this folder: ' . __DIR__;
  34. // or
  35. // save the card in file in the current folder
  36. // return $vcard->save();
  37. // echo message
  38. // echo 'A personal vCard is saved in this folder: ' . __DIR__;