PHP code example of jaredhowland / contacts

1. Go to this page and download the library: Download jaredhowland/contacts 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/ */

    

jaredhowland / contacts example snippets


            use \Contacts\Options; // Only needed if you must override the default settings
          use \Contacts\Vcard;

          // Set desired options
          $options = new Options();
          $options->setDataDirectory('./'); // Tell app where to save `.vcf` file

          $vcard = new Vcard($options);
          $vcard->addFullName('Jane Doe');
          $vcard->addName('Doe', 'Jane');
          $vcard->addNickname('Janie, Jan');
          $vcard->addPhoto('https://raw.githubusercontent.com/jaredhowland/contacts/master/tests/files/photo.jpg');
          $vcard->addBirthday(10, 2, null);
          $vcard->addAddress(null, null, '123 Main', 'Provo', 'UT', '84602', 'United States', ['dom', 'postal', 'parcel', 'work']);
          $vcard->addAddress(null, null, '123 Main', 'Provo', 'UT', '84602', 'United States', ['dom', 'postal', 'parcel', 'home']);
          $vcard->addLabel('Jane Doe\n123 Main St\nProvo, UT 84602', ['dom', 'parcel']);
          $vcard->addTelephone('555-555-5555', ['cell', 'iphone']);
          $vcard->addEmail('[email protected]');
          $vcard->addTimeZone('-7');
          $vcard->addLatLong(40.3333331, -111.7777775);
          $vcard->addTitle('System Administrator');
          $vcard->addRole('Programmer');
          // $vcard->addAgent($agent); NOT SUPPORTED
          $vcard->addOrganizations(['Awesome Company']);
          $vcard->addCategories(['School', 'Work']);
          $vcard->addNote('Not much is known about Jane Doe.');
          $vcard->addSortString('Doe');
          // $vcard->addSound($sound); NOT SUPPORTED
          $vcard->addUrl('https://www.example.com');
          // $vcard->addKey($key); NOT SUPPORTED
          $vcard->addAnniversary('2010-10-10');
          $vcard->addSupervisor('Jane Smith');
          $vcard->addSpouse('John Doe');
          $vcard->addChild('Jeff Doe');
          $vcard->addChild('Lisa Doe');
          $vcard->addExtendedType('TWITTER', '@jared_howland');
          $vcard->addUniqueIdentifier();
          $vcard->addRevision('2023-09-05'); // Added automatically if you don't call this method

          $directory->buildVcard(true, 'example');
       

            use \Contacts\Options;
          use \Contacts\Vcard;

          // Set desired options
          $options = new Options();
          $options->setDataDirectory('./'); // Tell app where to save `.vcf` file

          $vcard = new Vcard($options);
          $vcard->addFullName('Jane Doe')
                ->addName('Doe', 'Jane')
                ->addNickname('Janie, Jan')
                ->addPhoto('https://raw.githubusercontent.com/jaredhowland/contacts/master/tests/files/photo.jpg')
                ->addBirthday(10, 2, null)
                ->addAddress(null, null, '123 Main', 'Provo', 'UT', '84602', 'United States', ['dom', 'postal', 'parcel', 'work'])
                ->addAddress(null, null, '123 Main', 'Provo', 'UT', '84602', 'United States', ['dom', 'postal', 'parcel', 'home'])
                ->addLabel('Jane Doe\n123 Main St\nProvo, UT 84602', ['dom', 'parcel'])
                ->addTelephone('555-555-5555', ['cell', 'iphone'])
                ->addEmail('[email protected]')
                ->addTimeZone('-7')
                ->addLatLong(40.3333331, -111.7777775)
                ->addTitle('System Administrator')
                ->addRole('Programmer')
                ->addOrganizations(['Awesome Company'])
                ->addCategories(['School', 'Work'])
                ->addNote('Not much is known about Jane Doe.')
                ->addSortString('Doe')
                ->addUrl('http://www.example.com')
                ->addAnniversary('2010-10-10')
                ->addSupervisor('Jane Smith')
                ->addSpouse('John Doe')
                ->addChild('Jeff Doe')
                ->addChild('Lisa Doe')
                ->addExtendedType('TWITTER', '@jared_howland')
                ->addUniqueIdentifier()
                ->addRevision('2023-09-05') /* Added automatically with the current date and time if you don't call this method */
                ->buildVcard(true, 'example');
          // $vcard->addAgent($agent); NOT SUPPORTED
          // $vcard->addSound($sound); NOT SUPPORTED
          // $vcard->addKey($key); NOT SUPPORTED