PHPackages                             alexsoft12/simple\_calendar - 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. alexsoft12/simple\_calendar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alexsoft12/simple\_calendar
===========================

Framework-agnostic calendar generator for PHP

v1.0.0(3mo ago)03↓85%MITPHPPHP ^8.2

Since Mar 26Pushed 3mo agoCompare

[ Source](https://github.com/alexsoft12/simple_calendar)[ Packagist](https://packagist.org/packages/alexsoft12/simple_calendar)[ Docs](https://github.com/alexsoft12/simple_calendar)[ RSS](/packages/alexsoft12-simple-calendar/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Simple Calendar
===============

[](#simple-calendar)

[![PHP Version](https://camo.githubusercontent.com/c95d61c72a7dd6d1e6c04fb8a4e2dc54777a3b29d6bc151aa11c573ce6f224ba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e342532422d3737376262342e737667)](https://www.php.net/)[![License: MIT](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Framework-agnostic calendar generator for PHP 8.4+.

Screenshot
----------

[](#screenshot)

[![Screenshot](img/cal_screen.png)](img/cal_screen.png)

Highlights
----------

[](#highlights)

- Pure PHP core
- Immutable fluent API
- Built-in translations loaded from PHP files
- Bootstrap 4 friendly default template
- Fully customizable templates through arrays or JSON

Requirements
------------

[](#requirements)

- PHP 8.4+

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

[](#installation)

```
composer require alexsoft/simple_calendar
```

Basic Usage
-----------

[](#basic-usage)

```
use Simple\Calendar\CalendarGenerator;
use Simple\Calendar\DateProvider;
use Simple\Calendar\TemplateManager;

$calendar = new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
);

$html = $calendar->render(2026, 3);
```

The package does not ship any CSS. The default template only outputs simple HTML using familiar Bootstrap 4 classes.

Fluent API
----------

[](#fluent-api)

```
use Simple\Calendar\CalendarGenerator;
use Simple\Calendar\DateProvider;
use Simple\Calendar\Enums\DayFormat;
use Simple\Calendar\TemplateManager;

$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->bootstrap4()
    ->dayFormat(DayFormat::Long)
    ->navigation('https://example.test/reports/daily-sales', true)
    ->events([
        10 => 'Sales',
        15 => [
            [
                'title' => 'Total sales',
                'content' => '100.00',
                'attributes' => ['class' => 'sale-entry'],
            ],
        ],
    ])
    ->render();
```

Preconfigured Generator
-----------------------

[](#preconfigured-generator)

You can configure the generator once and then start a fluent chain from `month()`.

```
use Simple\Calendar\CalendarConfig;
use Simple\Calendar\CalendarGenerator;
use Simple\Calendar\DateProvider;
use Simple\Calendar\Enums\DayFormat;
use Simple\Calendar\Enums\MonthFormat;
use Simple\Calendar\TemplateManager;

$config = new CalendarConfig(
    monthFormat: MonthFormat::Long,
    dayFormat: DayFormat::Long,
    showNavigation: true,
    useSegments: true,
    navigationUrl: 'https://example.test/reports/daily-sales',
    locale: 'es',
    eventHtml: '{event}',
);

$calendar = new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
    $config,
);

$html = $calendar
    ->month(2026, 3)
    ->events([
        1 => 'Ventas',
    ])
    ->render();
```

Templates
---------

[](#templates)

Custom templates can be passed as arrays or JSON strings.

Bootstrap 4 Default
-------------------

[](#bootstrap-4-default)

```
$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->render();
```

### Array Template

[](#array-template)

```
$template = [
    'table_open' => '',
    'heading_row_start' => '',
    'heading_previous_cell' => '&lt;&lt;',
    'heading_title_cell' => '{heading}',
    'heading_next_cell' => '&gt;&gt;',
    'heading_row_end' => '',
    'week_row_start' => '',
    'week_day_cell' => '{week_day}',
    'week_row_end' => '',
    'cal_row_start' => '',
    'cal_cell_start' => '',
    'cal_cell_start_today' => '',
    'cal_cell_content' => '{day}{content}',
    'cal_cell_content_today' => '{day}{content}',
    'cal_cell_no_content' => '{day}',
    'cal_cell_no_content_today' => '{day}',
    'cal_cell_blank' => '&nbsp;',
    'cal_cell_end' => '',
    'cal_cell_end_today' => '',
    'cal_row_end' => '',
    'table_close' => '',
];

$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->template($template)
    ->render();
```

### JSON Template

[](#json-template)

```
$template = json_encode([
    'table_open' => '',
    'heading_row_start' => '',
    'heading_previous_cell' => '&lt;&lt;',
    'heading_title_cell' => '{heading}',
    'heading_next_cell' => '&gt;&gt;',
    'heading_row_end' => '',
    'week_row_start' => '',
    'week_day_cell' => '{week_day}',
    'week_row_end' => '',
    'cal_row_start' => '',
    'cal_cell_start' => '',
    'cal_cell_start_today' => '',
    'cal_cell_content' => '{day}{content}',
    'cal_cell_content_today' => '{day}{content}',
    'cal_cell_no_content' => '{day}',
    'cal_cell_no_content_today' => '{day}',
    'cal_cell_blank' => '&nbsp;',
    'cal_cell_end' => '',
    'cal_cell_end_today' => '',
    'cal_row_end' => '',
    'table_close' => '',
], JSON_THROW_ON_ERROR);
```

Events
------

[](#events)

`events()` accepts:

- `CalendarEventsByDay`
- `day => html`
- `day => [[title, content, attributes]]`
- `CalendarEvent`
- `CalendarEventData`

```
$dailySale = [
    5 => "Total250.00",
    9 => [
        [
            'title' => 'Total sales',
            'content' => '840.50',
            'attributes' => ['class' => 'daily-total'],
        ],
        [
            'title' => 'Shipping',
            'content' => '25.00',
        ],
    ],
];

$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->navigation('https://example.test/reports/daily-sales', true)
    ->events($dailySale)
    ->render();
```

Translations
------------

[](#translations)

The core ships with PHP file based translations in `src/lang`.

Included locales:

- `en`
- `es`

```
$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->locale('es')
    ->render();
```

You can also point to your own translation directory:

```
$html = (new CalendarGenerator(
    new TemplateManager(),
    new DateProvider(),
))
    ->month(2026, 3)
    ->locale('fr', __DIR__ . '/lang')
    ->render();
```

Default Markup
--------------

[](#default-markup)

The default template uses familiar Bootstrap 4 classes such as:

- `table`
- `table-bordered`
- `table-sm`
- `table-responsive`

The package does not inject styles. If your application does not use Bootstrap, provide your own template.

Security Notes
--------------

[](#security-notes)

- Event content is rendered as trusted HTML by design.
- Custom templates are rendered as trusted HTML by design.
- HTML attributes provided through event metadata are normalized and escaped before rendering.
- If event content comes from users, sanitize it before passing it to the package.
- If you use a custom translation directory, treat it as trusted application code because translation files are loaded as PHP.

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

This project is released under the [MIT License](LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance82

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38f843e6f2270ba6bf611bfe691a8518b046c2a9bd9bb94ce81c59a0ca005897?d=identicon)[alexsoft12](/maintainers/alexsoft12)

---

Top Contributors

[![alexsoft12](https://avatars.githubusercontent.com/u/15861110?v=4)](https://github.com/alexsoft12 "alexsoft12 (1 commits)")

---

Tags

phphtmlcalendarrendererframework agnostic

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/alexsoft12-simple-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/alexsoft12-simple-calendar/health.svg)](https://phpackages.com/packages/alexsoft12-simple-calendar)
```

###  Alternatives

[php-flasher/flasher

The foundational PHP library for PHPFlasher, enabling the creation of framework-agnostic flash notifications. Ideal for building custom integrations or for use in PHP projects.

634.7M41](/packages/php-flasher-flasher)[artem_c/emmet

emmet implementation for php

141.8k](/packages/artem-c-emmet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
