Download the PHP package mporcheron/free-busy-cal without Composer

On this page you can find all versions of the php package mporcheron/free-busy-cal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package free-busy-cal

Free/Busy Calendar - https://www.porcheron.uk/fbc

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:

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('[email protected]')
    ->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 = '<table class="cal">';

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

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

    // 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 .= '<tr><td class="time">'. $labels[0];
            if ($showRange) {
                $output .= '&nbsp;&ndash;&nbsp;' . $labels[1];
            }
            $output .= '</td>';

            foreach ($cal->getCalendarDates(Fbc\FreeBusyCalendar::DATE_FORMAT) as $dt) {
                if ($cal->isFree($dt->format('Y-m-d'), $hour, $minute)) {
                    $output .= '<td class="avail free">Free</td>';
                } else {
                    $output .= '<td class="avail busy">Busy</td>';
                }
            }
        }
        $output .= '</td>';
    }
    $output .= '</table>';

    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

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

Questions/Issues?

Please submit a GitHub issue. Documentation auto-generated from the code can be found on GitHub pages or the docs directory.


All versions of free-busy-cal with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.16
sabre/vobject Version ~4.0
sabre/dav Version ~3.2
sabre/xml Version ~1.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mporcheron/free-busy-cal contains the following files

Loading the files please wait ....