PHP code example of rumenx / php-calendar

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

    

rumenx / php-calendar example snippets


use Rumenx\Calendar;

// Create a calendar
$calendar = new Calendar();

// Add an event
$calendar->addEvent([
    'summary' => 'Team Meeting',
    'start' => '2025-08-15 10:00:00',
    'end' => '2025-08-15 11:00:00',
    'location' => 'Conference Room',
    'description' => 'Weekly team sync meeting'
]);

// Export as .ics file
$icsContent = $calendar->toIcs();

// Save to file or send as download
file_put_contents('meeting.ics', $icsContent);

// Generate calendar file for event registration confirmation
$calendar = new Calendar();
$calendar->addEvent([
    'summary' => 'PHP Conference 2025',
    'start' => '2025-09-20 09:00:00',
    'end' => '2025-09-20 17:00:00',
    'location' => 'Convention Center, Berlin',
    'description' => 'Annual PHP developers conference with talks and workshops.',
    'url' => 'https://phpconf2025.example.com'
]);

// Send as email attachment or download link
return response($calendar->toIcs())
    ->header('Content-Type', 'text/calendar')
    ->header('Content-Disposition', 'attachment; filename="phpconf2025.ics"');

// Doctor appointment with reminder
$calendar = new Calendar();
$calendar->addEvent([
    'summary' => 'Doctor Appointment',
    'start' => '2025-08-25 14:30:00',
    'end' => '2025-08-25 15:00:00',
    'location' => 'Medical Center, Room 205',
    'description' => 'Annual checkup with Dr. Smith',
    'alarm' => [
        'trigger' => '-PT30M', // 30 minutes before
        'description' => 'Appointment reminder'
    ]
]);

// Weekly standup meeting
$calendar = new Calendar();
$calendar->addEvent([
    'summary' => 'Daily Standup',
    'start' => '2025-08-01 09:00:00',
    'end' => '2025-08-01 09:15:00',
    'location' => 'Zoom Meeting Room',
    'description' => 'Daily team standup meeting',
    'rrule' => 'FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR;COUNT=50' // Weekdays only
]);

// Project kickoff with team
$calendar = new Calendar();
$calendar->addEvent([
    'summary' => 'Project Alpha Kickoff',
    'start' => '2025-08-10 13:00:00',
    'end' => '2025-08-10 14:30:00',
    'location' => 'Main Conference Room',
    'description' => 'Kickoff meeting for the new Alpha project',
    'attendees' => [
        'mailto:[email protected]',
        'mailto:[email protected]',
        'mailto:[email protected]'
    ],
]);

// In a controller
public function downloadEvent()
{
    $calendar = new Calendar();
    $calendar->addEvent([
        'summary' => 'Laravel Meetup',
        'start' => '2025-09-15 18:00:00',
        'end' => '2025-09-15 20:00:00',
    ]);

    return response($calendar->toIcs())
        ->header('Content-Type', 'text/calendar')
        ->header('Content-Disposition', 'attachment; filename="meetup.ics"');
}

// In a controller
public function downloadEvent(): Response
{
    $calendar = new Calendar();
    $calendar->addEvent([
        'summary' => 'Symfony Event',
        'start' => '2025-09-15 18:00:00',
        'end' => '2025-09-15 20:00:00',
    ]);

    return new Response(
        $calendar->toIcs(),
        200,
        [
            'Content-Type' => 'text/calendar',
            'Content-Disposition' => 'attachment; filename="event.ics"'
        ]
    );
}
bash
composer