PHP code example of xima-media / ical-bundle

1. Go to this page and download the library: Download xima-media/ical-bundle 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/ */

    

xima-media / ical-bundle example snippets


public function registerBundles()
{
    $bundles = array(
    ...
    new Xima\ICalBundle\XimaICalBundle()
}


use Doctrine\ORM\Mapping as ORM;

/**
 * ICalEvent.
 *
 * @ORM\Entity
 */
class ICalEvent extends \Xima\ICalBundle\Entity\Component\Event
{

}

/**
 * @Route("/ical")
 * Render all events as iCalendar
 */
protected function iCalAction(Array $events)
{
    $vCalendar = new \Eluceo\iCal\Component\Calendar('myCalendar');

    foreach ($events as $event) {
        $vCalendar->addComponent($event);
    }
    
    $response = new Response();
    $response->headers->set('Content-Type', 'text/calendar; charset=utf-8');
    $response->headers->set('Content-Disposition', 'inline; filename="cal.ics"');
    $response->setContent($vCalendar->render());

    return $response;
}