Open source PHP calendar library

v0.0.26 2016-11-04 02:18 UTC

README

Open source PHP Calendar library.

Installation & Setup

First, run the SQL create statements on your database:

sql/create.sked_events.sql
sql/create.sked_event_members.sql
sql/create.sked_event_tags.sql

Then, instantiate Sked in your code with data connection credentials:

$sked = new \CampusUnion\Sked([
    'data_connection' => [
        'name' => 'PDO',
        'options' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'dbname' => 'homestead',
            'user' => 'homestead',
            'pass' => 'secret',
        ],
    ],
]);

Basic usage

Event form

echo $sked->form();

Saving events to the database

$sked->save(new SkeVent($_POST));

Build a custom calendar by iterating through a specified date range:

foreach ($sked->skeDates('2016-08-05', '2016-09-21')) {
    // do something awesome
}

The SkeDate Object

A SkeDate object is useful for populating a particular date in your calendar UI.

Print the date using the format() method, which accepts a formatting string as an optional parameter (see formatting options for PHP's date function):

echo $skeDate->format('j'); // default format is 'Y-m-d' (e.g., 2016-08-05)

Then you can iterate through its events:

foreach ($skeDate->skeVents(/* Optionally pass a user ID to get events for a certain user. */)) {
    // do something awesome
}

The SkeVent Object

A SkeVent object allows for easy access and manipulation of an event.

Retrieve any database field (see SQL queries) as a property:

echo $skeVent->label;

Print the event time using the time() method, which accepts a formatting string as an optional parameter (see formatting options for PHP's date function):

echo $skeVent->time('Hi'); // default format is 'g:ia' (e.g., 2:15pm)

SkeVent::time() accepts a second optional parameter for timezone adjustment. To adjust the event's time to a particular timezone, just pass in the timezone offset integer:

echo $skeVent->time(null, -5); // outputs the time adjusted for US Eastern Standard time

Basic-er Usage

For an instant, non-customized event form, use the magical skeDoosh() method. The only required configuration is connection parameters for your data store. Call skeDoosh() from the exact spot in your code where you want the HTML form to be displayed:

Sked::skeDoosh([
    'data_connector' => [
        'name' => 'PDO',
        'options' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'dbname' => 'homestead',
            'user' => 'homestead',
            'pass' => 'secret',
        ],
    ],
]);