A bundle for handling events in calendar

Installs: 18 559

Dependents: 0

Suggesters: 0

Security: 0

Stars: 42

Watchers: 8

Forks: 16

Open Issues: 9


2.5.3 2016-03-30 15:11 UTC


Build Status

The CalendarBundle gives you a built-in calendar for managing events without relying on third-parties like Google. It comes with four different default views; agenda, by day, by week and by month. If you need greater customizations, you can use the bundle as a simple calendar API and build your own logic on it.


1. Update your vendors

Add this line to your composer.json

"require": {
    "carlescliment/calendar-bundle": "dev-master"

Execute php composer.phar update carlescliment/calendar-bundle

2. Load the bundle in app/AppKernel.php

$bundles = array(
    // ...
    new BladeTester\CalendarBundle\BladeTesterCalendarBundle(),

3. Update your routing:

// ...

    resource: "@BladeTesterCalendarBundle/Resources/config/routing.yml"
    prefix:   /

4. Create your calendar bundle

Create a new bundle extending BladeTesterCalendarBundle

namespace Your\OwnCalendarBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class YourOwnCalendarBundle extends Bundle

   public function getParent()
        return 'BladeTesterCalendarBundle';

WARNING: If your bundle includes its own routing file, remember to delete it or completely override the parent bundle paths.

Add it to AppKernel.

    $bundles = array(
        // ...
        new Your\OwnCalendarBundle\YourOwnCalendarBundle(),

5. Update the schema

php app/console doctrine:schema:update --force

6. Install the assets

php app/console assets:install

Using the calendar

Go to and enjoy :)

Customizing the bundle

If you want to override the bundle default views to use your design and markup, please follow the next steps.

1. Override the default base template

Copy the template in Resources/views/Base/base.html.twig into your own bundle and modify it to extend your base template.

2. Add the assets to your base template

<script type="text/javascript" src="{{ asset('bundles/bladetestercalendar/js/jquery-1.9.1.min.js') }}"></script>
<link rel="stylesheet" href="{{ asset('bundles/bladetestercalendar/css/calendar.css') }}" />
<script type="text/javascript" src="{{ asset('bundles/bladetestercalendar/js/calendar.js') }}"></script>

Note: remove the line including jquery if your template already includes it.

How to override the default entities

You can define your own entities. First, create your custom entity:

namespace Your\OwnCalendarBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use BladeTester\CalendarBundle\Entity\Event as BaseEvent;

 * @ORM\Entity(repositoryClass="BladeTester\CalendarBundle\Repository\EventRepository")
 * @ORM\Table(name="events")
class Event extends BaseEvent
  // ... your implementation goes here

Then modify your app/config/config.yml

        driver: doctrine/orm
        engine: twig
                entity: Your\OwnBundle\Entity\Event
                entity: Your\OwnBundle\Entity\EventCategory

Extending the behaviour

It is easy to extend the behaviour of this bundle by using inheritance in your models and entities. If it is not enough, you can register listeners to the calendar events.

Pre-persist event

Dispatched whenever an item is about to be created in the database.

        class: Your\OwnCalendarBundle\Event\CalendarListener
          - { name: kernel.event_listener, event: calendar.pre-persist, method: onPrePersist }
namespace Your\OwnCalendarBundle\Event;

use BladeTester\CalendarBundle\Event\CalendarEvent;

class CalendarListener {

    public function onPrePersist(CalendarEvent $event) {
        $event_model = $event->getEvent();
        // do whatever with the object before persisting it.

Post-add event

Dispatched after an item is added to the database.

        class: Your\OwnCalendarBundle\Event\CalendarListener
          - { name: kernel.event_listener, event:, method: onPostAdd }

Post-update event

Dispatched after an item is updated.

        class: Your\OwnCalendarBundle\Event\CalendarListener
          - { name: kernel.event_listener, event:, method: onPostUpdate }


CalendarBundle contains unitary and functional tests. Download the bundle, create the database according to the travis.yml file and configure the access settings in src/BladeTester/CalendarBundle/Tests/App/parameters.ini. Run the following command:

cd /path/to/calendar-bundle
composer update
php vendor/bin/phpunit


Contribute and feedback

Any feedback and contribution will be very appreciated.