1. Go to this page and download the library: Download plummer/calendarful 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/ */
plummer / calendarful example snippets
use Plummer\Calendarful\Event\EventInterface;
class Event implements EventInterface
{
}
use Plummer\Calendarful\Event\RecurrentEventInterface;
class RecurrentEvent implements RecurrentEventInterface
{
}
use \Plummer\Calendarful\Event\EventRegistryInterface;
class EventRegistry implements EventRegistryInterface
{
public function getEvents(array $filters = array())
{
$events = [];
$results = \TestEvent::where('startDate', '<=', $filters['toDate']->format('Y-m-d'))
->where('endDate', '>=', $filters['fromDate']->format('Y-m-d'))
->whereNull('type')->get();
foreach($results as $event) {
$events[$event->getId()] = $event;
}
return $events;
}
public function getRecurrentEvents(array $filters = array())
{
$recurrentEvents = [];
$results = \TestRecurrentEvent::whereNotNull('type')
->where(
function ($query) use ($filters) {
$query->whereNull('until')
->where('until', '>=', $filters['fromDate']->format('Y-m-d'), 'or');
})->get();
foreach($results as $event) {
$recurrentEvents[$event->getId()] = $event;
}
return $recurrentEvents;
}
}
$eventsRegistry = new EventRegistry();
$calendar = Plummer\Calendarful\Calendar\Calendar::create()
->populate($eventsRegistry, new \DateTime('2014-04-01'), new \DateTime('2014-04-30'));
foreach($calendar as $event) {
// Use event as necessary...
}
$eventsRegistry = new EventRegistry();
$recurrenceFactory = new \Plummer\Calendarful\Recurrence\RecurrenceFactory();
$recurrenceFactory->addRecurrenceType('daily', 'Plummer\Calendarful\Recurrence\Type\Daily');
$recurrenceFactory->addRecurrenceType('weekly', 'Plummer\Calendarful\Recurrence\Type\Weekly');
$recurrenceFactory->addRecurrenceType('monthly', 'Plummer\Calendarful\Recurrence\Type\MonthlyDate');
$calendar = Plummer\Calendarful\Calendar\Calendar::create($recurrenceFactory)
->populate($eventsRegistry, new \DateTime('2014-04-01'), new \DateTime('2014-04-30'));
$recurrenceFactory = new \Plummer\Calendarful\Recurrence\RecurrenceFactory();
$recurrenceFactory->addRecurrenceType('ThisShouldMatchAnEventRecurrenceTypePropertyValue', 'Another\RecurrenceType\ClassPath');
$calendarFactory = new \Plummer\Calendarful\Calendar\CalendarFactory();
$calendarFactory->addCalendarType('gregorian', 'Plummer\Calendarful\Calendar\Calendar');
$calendarFactory->addCalendarType('anotherType', 'Another\CalendarType\ClassPath');