API reference
This page lists the package's public operations. The linked guides explain semantics and errors; public readonly fields are documented in the guide for each object.
Read a calendar
ICalendar provides these input methods:
read(string $contents): Calendar
tryRead(string $contents): ?Calendar
fromPath(string $path): Calendar
tryFromPath(string $path): ?Calendar
fromStream(mixed $stream): Calendar
tryFromStream(mixed $stream): ?Calendar
fromUploadedFile(UploadedFile $file): Calendar
tryFromUploadedFile(UploadedFile $file): ?Calendarread()/tryRead()read a complete iCalendar string.fromPath()/tryFromPath()read a local regular file.fromStream()/tryFromStream()read from a stream's current position.fromUploadedFile()/tryFromUploadedFile()read a Laravel uploaded file.
A try*() method returns null only for invalid iCalendar content. See Reading input for source behavior and exceptions.
Query events, todos, and warnings
$calendar->events(?string $uid = null): Collection
$calendar->hasEvents(?string $uid = null): bool
$calendar->event(string $uid): ?Event
$calendar->todos(?string $uid = null): Collection
$calendar->hasTodos(?string $uid = null): bool
$calendar->todo(string $uid): ?Todo
$calendar->eventsBetween(DateTimeInterface $from, DateTimeInterface $until): Collection
$calendar->warnings(): Collectionevents()andtodos()return all components, or every exact UID match, in document order.hasEvents()andhasTodos()test whether any component or UID match exists.event()andtodo()return one exact UID match ornull.eventsBetween()returns events overlapping the requested half-open interval.warnings()returns issues that did not prevent a result.
UID matching is case-sensitive. Singular UID lookup prefers the recurrence master when one is present. eventsBetween() uses a half-open interval and does not expand recurrence rules. See Calendars, events, and todos.
Query properties
Calendar, Event, Todo, and Component expose:
$object->properties(?string $name = null): Collection
$object->hasProperty(?string $name = null): bool
$object->property(string $name): ?PropertyProperty and participant objects expose:
$property->parameters(): array
$property->parameter(string $name): string|array|null
$property->rawValue(): string
$property->toArray(): array
$organizer->parameters(): array
$attendee->parameters(): arrayproperties()returns all direct properties or every name match.hasProperty()tests whether any direct property or name match exists.property()returns the first name match ornull.parameters()returns all parameters without dropping multi-value entries.parameter()returns one parameter, an array for a multi-value parameter, ornull.rawValue()returns the property's text value.Property::toArray()returns the complete serializable property representation.
Names are case-insensitive and direct lookup does not recurse. See Properties and components.
Query components
$calendar->components(?string $name = null): Collection
$calendar->hasComponent(?string $name = null): bool
$calendar->component(string $name): ?Component
$component->components(?string $name = null): Collectioncomponents()returns all direct children or every name match.hasComponent()tests whether the Calendar has any direct child or name match.component()returns the Calendar's first name match ornull.
Component names are case-insensitive and only direct children are examined.
Event and alarm helpers
$event->isAllDay(): bool
$trigger->isRelative(): bool
$trigger->isAbsolute(): bool
$trigger->duration(): ?DateInterval
$trigger->dateTime(): ?CarbonImmutable
$trigger->relatedTo(): ?stringisAllDay()reports whetherDTSTARTuses the DATE value type.isRelative()andisAbsolute()identify the trigger form.duration()returns a relative trigger offset ornull.dateTime()returns an absolute trigger time ornull.relatedTo()returnsSTART,END, ornullfor an absolute trigger.
See Participants and alarms for relative and absolute trigger behavior.
Convert or access complete data
$calendar->toArray(): array
$calendar->jsonSerialize(): array
$calendar->toJson(int $options = 0): string
$calendar->toComponentArray(): array
$calendar->rawComponent(): VCalendar
$event->rawComponent(): VEvent
$todo->rawComponent(): VTodo
$component->rawComponent(): SabreComponenttoArray()andjsonSerialize()return Calendar, Event, Todo, and warning data.toJson()JSON-encodes that data with the supplied PHP options.toComponentArray()returns the complete property and component tree.- Each
rawComponent()returns an independent Sabre component for advanced use.
See Arrays and JSON.
Inspect issues
$issue->toArray(): array
$issue->jsonSerialize(): array
$exception->issues(): CollectionCalendarIssue::toArray()andjsonSerialize()return one issue's seven fields.InvalidCalendar::issues()returns every reason the content was rejected.