PHPackages                             sclinternet/bm-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. sclinternet/bm-calendar

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

sclinternet/bm-calendar
=======================

Calendar module which provide the ability to block off days.

161.1k4[1 issues](https://github.com/SCLInternet/BmCalendar/issues)PHP

Since Jul 18Pushed 12y ago4 watchersCompare

[ Source](https://github.com/SCLInternet/BmCalendar)[ Packagist](https://packagist.org/packages/sclinternet/bm-calendar)[ RSS](/packages/sclinternet-bm-calendar/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

BmCalendar
==========

[](#bmcalendar)

[![Build Status](https://camo.githubusercontent.com/4eb2d7ce6c481214df741fcfd433ef2ed4dd29698d58b7a5ffbadeeeb9ca26fa/68747470733a2f2f7472617669732d63692e6f72672f53434c496e7465726e65742f426d43616c656e6461722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/SCLInternet/BmCalendar)[![Coverage Status](https://camo.githubusercontent.com/8bc9c34dae305d5d9f5dea009f41d4582626c0f6298e5ef447fd7bcfd70b29a9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f53434c496e7465726e65742f426d43616c656e6461722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/SCLInternet/BmCalendar?branch=master)

Calendar module which provide the ability to block off days.

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

[](#installation)

Installation can be done easily via composer by running:

`composer.php require sclinternet/bm-calendar`

When prompted for a version enter `dev-master`.

After the composer has completed simple add `BmCalendar` to the `modules`section in your application config.

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

[](#basic-usage)

Simply create a calendar like so:

```
$calendar = new \BmCalendar\Calendar();
```

And the use the view helper to display a month in your view:

```
echo $this->calendar($calendar)->showMonth(2013, 05);
```

The View Helper
---------------

[](#the-view-helper)

By default the view helper will render a month in a simple HTML table created by `BmCalendar\Renderer\HtmlCalendar`.

Changing the start day
======================

[](#changing-the-start-day)

By default the calendar will render with Monday days in the first column, if you wish to change this you can invoke the view helper like so.

```
echo $this->calendar($calendar)
          ->setStartDay(\BmCalendar\DayInterface::WEDNESDAY)
          ->showMonth(2013, 5);
```

Renderer Classes
================

[](#renderer-classes)

You can also create your own renderer classes by implementing `BmCalendar\Renderer\RendererInterface` then tell the view helper to use your renderer instead like so:

```
echo $this->calendar($calendar)->setRenderer(new MyRenderer())->showMonth(2013, 5);
```

Partials
========

[](#partials)

Alternatively you can customise the rendering process by using partial templates.

To do this simply call the view helper like so:

```
echo $this->calendar($calendar)->setPartial('partial-name')->showMonth(2013, 5);
```

The partial will have the following parameters passed to it:

- **$startDay** - The day of the week to start the calendar on (int 1-7)
- **$calendar** - An instance of `BmCalendar\Calendar`
- **$month** - The month to be rendered (int)
- **$year** - The year that the month to be rendered belongs to (int)

Day Providers
-------------

[](#day-providers)

Day providers are used to add extra states to a day.

States must implement `\BmCalendar\State\DayStateInterface`.

A day provider can be implemented like so:

```
use BmCalendar\DayProviderInterface;
use BmCalendar\Day;
use BmCalendar\Month;

class MyDayProvider implements DayProviderInterface
{
    public $database;

    public function createDay(Month $month, $dayNo)
    {
        $day = new Day($month, $dayNo);

        $avaliable = $this->database->checkAvailability(
            $month->getYear()->value(),
            $month->value(),
            $dayNo
        );

        if (!$available) {
            $day->addState(new BookedState());

            return $day;
        }

        $day->addState(new AvailableState());
        $day->setAction('http://url-to-booking-form');

        return $day;
    }
}
```

To use your day provider simply pass it to the Calendar constructor like so:

```
$provider = new MyDayProvider();
$provider->database = new AvailabilityDatabasesChecker();

$calendar = new \BmCalendar\Calendar($provider);
```

Day States
----------

[](#day-states)

Day states allow you to add values to days in the calendar (e.g. if there is an event on on that day).

### Creating a day state class

[](#creating-a-day-state-class)

A day state is a class which implements `BmCalendar\State\DayStateInterface` which simply provides a static method called `type()` to identify the state by.

There is also a `BmCalendar\State\AbstractDayState` class available which can be directly extended which will implement the `type()` method for you.

You can quickly define a state like so:

```
use BmCalendar\State\AbstractDayState;

class HasEventState extends AbstractDayState
{
}
```

### Using day states

[](#using-day-states)

To add a state to a `Day` object you simply call the `addState($state)` method:

```
$day->addState(new HasEventState())
```

To get a list of all states attached to a `Day` object you can call

```
$day->getStates();
```

An if you want to check for a specific type of state for a given day you can use the static `type()` method like so:

```
$state = $day->getState(HasEventState::type());
```

If the `Day` doesn't contain a state of the requested type `NULL` is returned.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1959183?v=4)[Tom Oram](/maintainers/tomphp)[@tomphp](https://github.com/tomphp)

---

Top Contributors

[![Felix3142](https://avatars.githubusercontent.com/u/4006463?v=4)](https://github.com/Felix3142 "Felix3142 (9 commits)")[![robertmarsal](https://avatars.githubusercontent.com/u/507871?v=4)](https://github.com/robertmarsal "robertmarsal (1 commits)")

### Embed Badge

![Health badge](/badges/sclinternet-bm-calendar/health.svg)

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

###  Alternatives

[norberttech/static-content-generator-bundle

Generate static html pages from your symfony application

374.1k](/packages/norberttech-static-content-generator-bundle)[schmeits/filament-4-phosphor-icons

This is my package filament-4-phosphor-icons

172.9k](/packages/schmeits-filament-4-phosphor-icons)

PHPackages © 2026

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