PHPackages                             jean-sebastien-christophe/ux-calendar-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jean-sebastien-christophe/ux-calendar-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

jean-sebastien-christophe/ux-calendar-bundle
============================================

A modern calendar bundle for Symfony 8 with Turbo and Stimulus, without FullCalendar

v1.0.4(1mo ago)215MITPHPPHP &gt;=8.4CI passing

Since Dec 7Pushed 1mo agoCompare

[ Source](https://github.com/JsD3v/ux-calendar-bundle)[ Packagist](https://packagist.org/packages/jean-sebastien-christophe/ux-calendar-bundle)[ RSS](/packages/jean-sebastien-christophe-ux-calendar-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (65)Versions (22)Used By (0)

CalendarBundle for Symfony 8
============================

[](#calendarbundle-for-symfony-8)

[![Tests](https://github.com/JsD3v/ux-calendar-bundle/actions/workflows/test.yml/badge.svg)](https://github.com/JsD3v/ux-calendar-bundle/actions/workflows/test.yml)[![PHPStan](https://github.com/JsD3v/ux-calendar-bundle/actions/workflows/phpstan.yml/badge.svg)](https://github.com/JsD3v/ux-calendar-bundle/actions/workflows/phpstan.yml)

A lightweight calendar bundle for Symfony 8, built on Turbo, Stimulus and AssetMapper. It provides month, week and day views, event management forms and EasyAdmin helpers, without a heavy JavaScript dependency such as FullCalendar. No third-party CDNs are loaded by default.

Compatibility
-------------

[](#compatibility)

- PHP &gt;= 8.4
- Symfony FrameworkBundle, Form, Validator, TwigBundle, Console, Translation and AssetMapper `^8.0`
- Symfony UX Turbo and Stimulus Bundle `^2.0|^3.0`
- Doctrine ORM `^2.0|^3.0` and DoctrineBundle `^2.0|^3.0`
- EasyAdmin `^4.0|^5.0`, optional, for the admin panel
- Symfony UX ChartJS `^2.0|^3.0`, optional, for the dashboard charts

Features
--------

[](#features)

- Month, week and day views with a built-in switcher and Turbo Streams updates
- Week and day views rendered as an hourly grid (0:00–23:00 slots), plus an "all-day" row
- Create, edit, delete and one-off date exclusion
- Ready-to-use `Event` entity
- `CalendarEventInterface` and `CalendarEventRepositoryInterface` contracts for custom entities
- `CalendarEventTrait` to reuse the common Doctrine mapping
- Bootstrap theme by default, with `default` and `tailwind` variants and optional automatic detection
- Optional EasyAdmin CRUD, calendar field and dashboard widget

Installation
------------

[](#installation)

```
composer require jean-sebastien-christophe/ux-calendar-bundle
```

Register the bundle in `config/bundles.php`:

```
JeanSebastienChristophe\CalendarBundle\CalendarBundle::class => ['all' => true],
```

Declare the routes in `config/routes/calendar.yaml`:

```
calendar_bundle:
    resource: '@CalendarBundle/src/Controller/'
    type: attribute
```

The default route is `/events`. To use `/calendar` instead, create `config/packages/calendar.yaml`:

```
calendar:
    theme: bootstrap
    assets:
        include_cdn: false
    route_prefix: /calendar
    views:
        enabled: [month, week, day]
        default: month
    features:
        all_day_events: true
        colors: true
```

Create and apply the Doctrine migration:

```
php bin/console make:migration
php bin/console doctrine:migrations:migrate
php bin/console cache:clear
```

The CSS assets are exposed through AssetMapper. No `assets:install` command is required.

The default theme is `bootstrap`, to stay consistent with EasyAdmin and the classes used by the templates. The `bootstrap.css` theme only maps the `--bs-*` variables: **Bootstrap itself must therefore be loaded**, otherwise the classes (`btn`, `container`, `alert`, …) used in the templates are left unstyled. There are two ways to provide it:

1. **Through your application's AssetMapper (recommended).** The calendar's standalone pages automatically render `importmap('app')` (see the Stimulus section). If your `importmap.php` imports Bootstrap (for example `import 'bootstrap/dist/css/bootstrap.min.css'` in `assets/app.js`), it is loaded on `/events` with nothing else to do.
2. **Through the Bootstrap CDN**, useful for a standalone rendering when the application does not embed Bootstrap:

```
calendar:
    theme: bootstrap
    assets:
        include_cdn: true
```

The `tailwind`, `default` and `auto` themes remain available through `calendar.theme`.

Stimulus
--------

[](#stimulus)

The Stimulus controller is exposed as a Symfony UX controller. Enable it in `assets/controllers.json`:

```
{
    "controllers": {
        "@jean-sebastien-christophe/ux-calendar-bundle": {
            "calendar": {
                "enabled": true,
                "fetch": "eager"
            }
        }
    }
}
```

Your application must start StimulusBundle, for example in `assets/bootstrap.js`:

```
import { startStimulusApp } from '@symfony/stimulus-bundle';

startStimulusApp();
```

The calendar's standalone pages (the `@Calendar/calendar/base.html.twig` layout) **automatically** render the `importmap('app')` entrypoint. This is what loads, on `/events`, both the `calendar` Stimulus controller and your application's assets (including Bootstrap if it is in your `importmap.php`). Your application must therefore expose an entrypoint named `app` (the Symfony default).

If your entrypoint has a different name, override the `importmap` block by creating `templates/bundles/CalendarBundle/calendar/base.html.twig`:

```
{% extends '@Calendar/calendar/base.html.twig' %}

{% block importmap %}
    {{ importmap('my_entrypoint') }}
{% endblock %}
```

To embed the calendar in your own layout (instead of the standalone page), override the same template so that it extends your application's layout:

```
{# templates/bundles/CalendarBundle/calendar/base.html.twig #}
{% extends 'base.html.twig' %}

{% block body %}
    {{ calendar_theme_css()|raw }}
    {% block calendar_body %}{% endblock %}
{% endblock %}
```

Then open `/events`, or `/calendar` if you configured `route_prefix: /calendar`.

Exposed routes
--------------

[](#exposed-routes)

`{prefix}` defaults to `/events`.

MethodRouteNameDescriptionGET`{prefix}``calendar_index`Redirects to the default view (`views.default`)GET`{prefix}/{year}/{month}``calendar_month`Renders the monthly calendarGET`{prefix}/week/{date}``calendar_week`Renders the week containing `{date}` (`Y-m-d`)GET`{prefix}/day/{date}``calendar_day`Renders the `{date}` day (`Y-m-d`)GET, POST`{prefix}/new``calendar_event_new`Renders the form and creates the eventGET, POST`{prefix}/{id}/edit``calendar_event_edit`Renders the form and updates the eventPOST`{prefix}/{id}/exclude/{date}``calendar_event_exclude_date`Excludes a date for an eventPOST, DELETE`{prefix}/{id}``calendar_event_delete`Deletes the eventCustom entity
-------------

[](#custom-entity)

The default entity is `JeanSebastienChristophe\CalendarBundle\Entity\Event`. To use your own entity, it must implement `CalendarEventInterface`. The `CalendarEventTrait` provides the common Doctrine mapping.

You can configure the entity with the install command:

```
php bin/console ux-calendar:install --event-class='App\Entity\MyEvent'
```

```
