PHP code example of beastbytes / icalendar

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

    

beastbytes / icalendar example snippets


$vCalendar = (new Vcalendar())
    ->addProperty(Vcalendar::PROPERTY_UID, Vcalendar::uuidv4())
    ->addComponent((new Vevent())
        ->addProperty(Vevent::PROPERTY_UID, Vevent::uuidv4())
    )
;

use BeastBytes\ICalendar\Component;

class NonStandardComponent extends Component
{
    public const NAME = 'NON-STANDARD-COMPONENT';

    protected const CARDINALITY = [
        // declare cardinality of the component's properties here
    ];
}
---
Vcalendar::registerNonStandardComponent(NonStandardComponent::NAME);

$nonStandardComponent = new NonStandardComponent();

$vCalendar = (new Vcalendar())->addComponent($nonStandardComponent);
// $vCalendar->hasComponent(NonStandardComponent::NAME) === true;

public const NON_STANDARD_PROPERTY = 'NON-STANDARD-PROPERTY';

Vevent::registerNonStandardProperty(self::NON_STANDARD_PROPERTY, Vevent::CARDINALITY_ONE_MAY);

$vEvent = (new Vevent())->addProperty(self::NON_STANDARD_PROPERTY, $value);
// $vEvent->hasProperty(self::NON_STANDARD_PROPERTY) === true;

$iCalendar = (new Vcalendar())
    ->addProperty(Vcalendar::PROPERTY_PRODUCT_IDENTIFIER, '-//ABC Corporation//NONSGML My Product//EN')
    ->addComponent((new Vtodo())
        ->addProperty(Vtodo::PROPERTY_DATETIME_STAMP, '19980130T134500Z')
        ->addProperty(Vtodo::PROPERTY_SEQUENCE, 2)
        ->addProperty(Vtodo::PROPERTY_UID, Vtodo::uuidv4())
        ->addProperty(Vtodo::PROPERTY_ORGANIZER, 'mailto:[email protected]')
        ->addProperty(
            Vtodo::PROPERTY_ATTENDEE,
            'mailto:[email protected]',
            [
                Vtodo::PARAMETER_PARTICIPATION_STATUS => Vtodo::STATUS_ACCEPTED
            ]
        )
        ->addProperty(Vtodo::PROPERTY_DATETIME_DUE, '19980415T000000')
        ->addProperty(Vtodo::PROPERTY_STATUS, Vtodo::STATUS_NEEDS_ACTION)
        ->addProperty(Vtodo::PROPERTY_SUMMARY, 'Submit Income Taxes')
        ->addComponent((new Valarm())
            ->addProperty(Valarm::PROPERTY_ACTION, Valarm::ACTION_AUDIO)
            ->addProperty(Valarm::PROPERTY_TRIGGER, '19980403T120000Z')
            ->addProperty(
                Valarm::PROPERTY_ATTACH,
                'http://example.com/pub/audio-files/ssbanner.aud',
                [
                    Valarm::PARAMETER_FORMAT_TYPE => 'audio/basic'
                ]
            )
            ->addProperty(Valarm::PROPERTY_REPEAT, 4)
            ->addProperty(Valarm::PROPERTY_DURATION, 'PT1H')
        )
    )
    ->render()
;

$icalendar = Vcalendar::import($string);

php composer.phar