PHPackages                             mporcheron/free-busy-cal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mporcheron/free-busy-cal

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

mporcheron/free-busy-cal
========================

Produce a free/busy calendar of availability from iCal files or CalDAV server calendars.

v0.4.1(8y ago)7213MITPHPPHP &gt;=5.4.16

Since Feb 12Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mporcheron/free-busy-cal)[ Packagist](https://packagist.org/packages/mporcheron/free-busy-cal)[ RSS](/packages/mporcheron-free-busy-cal/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

Free/Busy Calendar -
===================================================

[](#freebusy-calendar---httpswwwporcheronukfbc)

Usage
-----

[](#usage)

An example usage can be found in `example.php`. This file connects to a CalDAV server, extracts two weeks of dates (excluding weekends) and generates an HTML table. A sample walkthough of the code is below:

If you are loading an iCal file, use the `Calendar` class:

```
$cal = (new MPorcheron\FreeBusyCal\Calendar())->setFile('calendar.ics');

```

Alternatively:

- if the file is accessed over the internet, use the `setUrl(url)` function instead of `setFile(file)`.
- if you have the calendar source inside a string, use the function `setiCal(source)`

Howevever, if your calendar is retrieved from a CalDAV server and not an ICS file, use the `CalDAVCalendar` class:

```
$iCloud = (new MPorcheron\FreeBusyCal\CalDAVCalendar())
    ->setUsername('my.apple.id@me.com')
    ->setPassword('application-specific-password')
    ->setPrincipalUrl('https://caldav.icloud.com/123456789876543/principal/');

```

Create the `Generator` object and add one or more calendars:

```
$fbc = new \MPorcheron\FreeBusyCal\Generator($cal, $iCloud);

```

Set the date range to extract, e.g. start from this Monday, and run for 14 days (i.e. two weeks), but exclude weekends:

```
$fbc->setDateRange(new \DateTime('Monday this week'), 14, false);

```

Only generate a calendar between 9am (inclusive) and 5pm (exclusive):

```
$fbc->setTimeRange(9, 17);

```

Fetch the calendars and process them:

```
$fbc->fetchAndParse();

```

Print out the calendar as a table, default date and time formats, the labels `Free` and `Busy` for slots, and show times as ranges (i.e. start – end):

```
$contents = $fbc->generate(function (Fbc\FreeBusyCalendar &$cal) {
    $output = '';

    // Output table headers with days
    $output .= '';
    $days = [ 'S', 'M', 'T', 'W', 'T', 'F', 'S' ];
    foreach ($cal->getCalendarDates(Fbc\FreeBusyCalendar::DATE_FORMAT) as $label => &$dt) {
        $output .= ''. $days[$dt->format('N')] .'';
    }
    $output .= '';

    // Output table headers with dates
    $output .= '';
    foreach ($cal->getCalendarDates(Fbc\FreeBusyCalendar::DATE_FORMAT) as $label => &$dt) {
        $output .= ''. $label .'';
    }
    $output .= '';

    // Iterate through each time and $output .= the availability
    $times = $cal->getCalendarTimes(Fbc\FreeBusyCalendar::TIME_FORMAT);
    foreach ($times as $hour => $temp) {
        foreach ($temp as $minute => $labels) {
            $output .= ''. $labels[0];
            if ($showRange) {
                $output .= '&nbsp;&ndash;&nbsp;' . $labels[1];
            }
            $output .= '';

            foreach ($cal->getCalendarDates(Fbc\FreeBusyCalendar::DATE_FORMAT) as $dt) {
                if ($cal->isFree($dt->format('Y-m-d'), $hour, $minute)) {
                    $output .= 'Free';
                } else {
                    $output .= 'Busy';
                }
            }
        }
        $output .= '';
    }
    $output .= '';

    return $output;
});

```

Alternatively test if a specific time/date (i.e. 5pm on 4th May 2016) is available:

```
 $cal = $fbc->getFreeBusyCalendar();
 $free = $cal->isFree('2016-05-04', 17, 0);

```

Testing
-------

[](#testing)

This has been tested with the ICS file from Office 365 and iCloud CalDAV.

Questions/Issues?
-----------------

[](#questionsissues)

Please submit a [GitHub issue](https://github.com/mporcheron/free-busy-cal). Documentation auto-generated from the code can be found on [GitHub pages](http://mporcheron.github.io/free-busy-cal/) or the `docs` directory.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~113 days

Total

6

Last Release

3245d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/844463?v=4)[Martin Porcheron](/maintainers/mporcheron)[@mporcheron](https://github.com/mporcheron)

---

Top Contributors

[![mporcheron](https://avatars.githubusercontent.com/u/844463?v=4)](https://github.com/mporcheron "mporcheron (45 commits)")

---

Tags

website

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mporcheron-free-busy-cal/health.svg)

```
[![Health](https://phpackages.com/badges/mporcheron-free-busy-cal/health.svg)](https://phpackages.com/packages/mporcheron-free-busy-cal)
```

###  Alternatives

[fisharebest/webtrees

webtrees online genealogy

73710.5k13](/packages/fisharebest-webtrees)[roundcube/carddav

CardDAV adapter for connecting to CardDAV-enabled addressbooks

28155.3k](/packages/roundcube-carddav)[lochmueller/calendarize

Create a structure for timely controlled tables (e.g. events) and one plugin for the different output of calendar views (list, detail, month, year, day, week...). The extension is shipped with one default event table, but you can also 'calendarize' your own table/model. It is completely independent and configurable! Use your own models as event items in this calender. Development on https://github.com/lochmueller/calendarize

77152.6k12](/packages/lochmueller-calendarize)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
