adesigns/calendar-bundle
Symfony2 bundle to integrate jQuery FullCalendar. Uses event listeners to load events from any bundle and provides an AJAX event loader route (via FOSJsRouting). Includes FullCalendar assets and simple Twig include to render the calendar.
Install Dependencies
composer require adesigns/calendar-bundle fos/jsrouting-bundle
Ensure FOSJsRoutingBundle is registered in AppKernel.php before CalendarBundle.
Configure the Bundle
Add to config.yml:
adesigns_calendar:
event_loader:
route: your_event_loader_route # Must match your AJAX route
First Use Case: Basic Calendar View
// src/Controller/CalendarController.php
use ADesigns\CalendarBundle\Controller\CalendarController;
class CalendarController extends CalendarController
{
public function indexAction()
{
return $this->renderCalendar();
}
}
# app/config/routing.yml
calendar:
resource: "@CalendarBundle/Resources/config/routing.yml"
prefix: /
/calendar to see the default FullCalendar UI.Define Event Entities
Annotate your event entity with ADesigns\CalendarBundle\Model\EventInterface:
use ADesigns\CalendarBundle\Model\EventInterface;
class Event implements EventInterface
{
// Required fields:
private $id;
private $title;
private $start;
private $end;
// ...
}
Create an Event Loader
Extend ADesigns\CalendarBundle\Event\EventLoaderInterface:
use ADesigns\CalendarBundle\Event\EventLoaderInterface;
class CustomEventLoader implements EventLoaderInterface
{
public function load($resourceId, $start, $end, $timezone, UserInterface $user = null)
{
return $this->getDoctrine()
->getRepository('AppBundle:Event')
->findByStartBetween($start, $end);
}
}
Register it in services.yml:
services:
app.event_loader:
class: AppBundle\Event\CustomEventLoader
tags:
- { name: adesigns_calendar.event_loader, resource: "events" }
Configure AJAX Endpoint Add a route for event fetching:
# app/config/routing.yml
app_calendar_events:
path: /calendar/events
defaults: { _controller: AppBundle\Controller\CalendarController::eventsAction }
Controller:
public function eventsAction(Request $request)
{
return $this->get('adesigns_calendar.event_loader')->load(
$request->query->get('resource'),
$request->query->get('start'),
$request->query->get('end'),
$request->query->get('timezone')
);
}
Render the Calendar in Twig
{{ render(controller('ADesignsCalendarBundle:Calendar:index', {
'resource': 'events',
'events': app.user
})) }}
Dynamic Timezones
Use timezone parameter in AJAX calls and handle it in the loader:
$timezone = new \DateTimeZone($request->query->get('timezone'));
$start->setTimezone($timezone);
Custom Views
Override templates in templates/ADesignsCalendarBundle/ to modify UI.
Recurring Events
Use ADesigns\CalendarBundle\Model\RecurringEventInterface and implement logic in your loader.
Event Editing
Extend ADesigns\CalendarBundle\Event\EventManagerInterface to handle CRUD operations.
FOSJsRouting Dependency
fos_js_routing.js causes AJAX routes to fail.FOSJsRoutingBundle is installed and the JS file is included in your layout:
{{ fos_js_routing_js() }}
Timezone Mismatches
eventSources: [{
url: Routing.generate('app_calendar_events', { timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }),
// ...
}]
Event Loader Caching
# config.yml
adesigns_calendar:
event_loader:
cache: false # Disable if real-time updates are needed
Archived Package Risks
fullcalendar-php for Laravel.Check AJAX Responses
Use browser dev tools to inspect the /calendar/events endpoint. Ensure:
start/end parameters are correctly formatted (ISO 8601).Symfony Debug Toolbar Enable the toolbar to inspect:
Frontend Console Errors FullCalendar logs errors to the browser console. Common issues:
eventSources configuration.title or start).Custom Event Data Extend the event model to include additional fields:
class Event implements EventInterface
{
private $color; // Custom field
// ...
}
Map it to FullCalendar:
eventRender: function(event, element) {
element.css('background-color', event.color);
}
Event Categories Use event categories for filtering:
class Event implements EventInterface
{
private $category;
// ...
}
Filter in JavaScript:
eventSources: [{
url: '/calendar/events',
color: 'category-specific-color',
textColor: 'white'
}]
Integration with Laravel (Symfony Alternative)
EventLoaderInterface with a Laravel service provider.php artisan route:cache) for FOSJsRouting.resources/views/vendor/adesigns-calendar.How can I help you explore Laravel packages today?