1. Go to this page and download the library: Download tito10047/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/ */
use Tito10047\Calendar\ICal\ICalParser;
use Tito10047\Calendar\ICal\ICalDataLoader;
$events = (new ICalParser())->parseUrl('https://calendar.google.com/.../basic.ics');
// Attach to the grid — recurring events expanded automatically
$calendar = Calendar::forMonth(2024, 11)
->setDataLoader(ICalDataLoader::fromEvents($events));
// Or expand occurrences for a custom range (RECURRENCE-ID overrides applied)
$occurrences = $events[0]->expandOccurrences($from, $to); // list<ICalEvent>
use Tito10047\Calendar\Serializer\JsonSerializer;
$events = (new ICalParser())->parseUrl('https://example.com/calendar.ics');
header('Content-Type: application/json');
echo JsonSerializer::fromEvents($events)
->forRange(new DateTimeImmutable('2025-01-01'), new DateTimeImmutable('2025-12-31'))
->toJson();
use Tito10047\Calendar\View\AgendaView;
use Tito10047\Calendar\View\AgendaGrouping;
$groups = AgendaView::fromEvents($events)
->forRange(new DateTimeImmutable('today'), new DateTimeImmutable('+30 days'))
->groupBy(AgendaGrouping::Day)
->getGroups();
foreach ($groups as $group) {
echo $group->getLabel(); // "Monday, 14 July 2025"
foreach ($group->getEvents() as $event) {
echo $event->dtStart->format('H:i') . ' ' . $event->summary;
}
}
use Tito10047\Calendar\ICal\CalDAVClient;
$events = (new CalDAVClient('https://cloud.example.com/remote.php/dav/calendars/jan/personal/'))
->authenticate('jan', 'app-password')
->fetchEvents(new DateTimeImmutable('2025-01-01'), new DateTimeImmutable('2025-12-31'));
use Tito10047\Calendar\Recurrence\RecurrenceRule;
use Tito10047\Calendar\Enum\DayName;
// Last working day of every month
RecurrenceRule::monthly()
->onDays(DayName::Monday, DayName::Tuesday, DayName::Wednesday, DayName::Thursday, DayName::Friday)
->bySetPos(-1);
// Every other Tuesday, max 10 times
RecurrenceRule::weekly()->onDays(DayName::Tuesday)->every(2)->count(10);
// 15th and last day of each month
RecurrenceRule::monthly()->onMonthDays(15, -1);
// Parse from iCal string
$rule = RecurrenceRule::fromRrule('FREQ=WEEKLY;BYDAY=MO,WE,FR;WKST=SU');
$day->date // DateTimeImmutable
$day->ghost // belongs to adjacent month (Monthly grid padding only)
$day->today // matches today's date
$day->enabled // not disabled by any rule
$day->data // ?array — whatever your DayDataLoaderInterface returned
Calendar::forMonth(2024, 11) // full month, aligned to complete weeks
Calendar::forWeek(new DateTimeImmutable('2024-11-04')) // one ISO week
Calendar::forToday(CalendarType::WorkWeek) // this work week
Calendar::fromDateRange($from, $to) // arbitrary date range
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.