PHPackages                             alrik11es/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. [Templating &amp; Views](/categories/templating)
4. /
5. alrik11es/calendar

ActiveLibrary[Templating &amp; Views](/categories/templating)

alrik11es/calendar
==================

An structured calendar generator in array, object or json format

1.0.0(9y ago)131.1k[1 issues](https://github.com/alrik11es/calendar/issues)MITPHPPHP &gt;=5.6

Since Aug 10Pushed 9y ago1 watchersCompare

[ Source](https://github.com/alrik11es/calendar)[ Packagist](https://packagist.org/packages/alrik11es/calendar)[ RSS](/packages/alrik11es-calendar/feed)WikiDiscussions 1.0 Synced 2w ago

READMEChangelog (3)Dependencies (1)Versions (7)Used By (0)

Calendar [![Build Status](https://camo.githubusercontent.com/126737d689fccb2eb78c9052db816da95665d83dcbc8ff6888ea0e0f459554f3/68747470733a2f2f7472617669732d63692e6f72672f616c72696b313165732f63616c656e6461722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alrik11es/calendar)
==============================================================================================================================================================================================================================================================================================

[](#calendar-)

[![Latest Stable Version](https://camo.githubusercontent.com/b5aa331077ac345a269d348ca718bd7b8578786518f21b08c796ecee235b8e45/68747470733a2f2f706f7365722e707567782e6f72672f616c72696b313165732f63616c656e6461722f762f737461626c652e737667)](https://packagist.org/packages/alrik11es/calendar) [![Total Downloads](https://camo.githubusercontent.com/ab8545a007936397bc8658f93bd4ea357a094a1ab436bec2ff0ffb06bc427ae7/68747470733a2f2f706f7365722e707567782e6f72672f616c72696b313165732f63616c656e6461722f646f776e6c6f6164732e737667)](https://packagist.org/packages/alrik11es/calendar) [![Latest Unstable Version](https://camo.githubusercontent.com/ddd130a16989bea4327ebebc3f3d36739e6cc82eb21ebc41a9657e29deac7cd2/68747470733a2f2f706f7365722e707567782e6f72672f616c72696b313165732f63616c656e6461722f762f756e737461626c652e737667)](https://packagist.org/packages/alrik11es/calendar) [![License](https://camo.githubusercontent.com/e2a3ee3d88d261f674ffd78567535fba82e9efaf79c18a4fa11e668636e4d1e3/68747470733a2f2f706f7365722e707567782e6f72672f616c72696b313165732f63616c656e6461722f6c6963656e73652e737667)](https://packagist.org/packages/alrik11es/calendar)

Calendar is a PHP calendar structure generator in array, object or JSON format.

- [Installation](#installation)
    - [Requirements](#requirements)
    - [With composer](#with-composer)
- [How it works](#how-it-works)

Motivation
----------

[](#motivation)

Do you remember those long... long... hours trying to create a rendered calendar? Think about this, the main problem is that you have to generate the structure to do the rendering in your template engine, no matter what it is. So the thing here is I don't wanna give you a fully rendered calendar just the structure you need to do the render. How do you do the render... it's all on you.

Take a look to this example render:

[![Calendar example](img/calendar.png "Calendar example")](img/calendar.png)

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

[](#installation)

### Requirements

[](#requirements)

- Any flavour of PHP 5.6+ should do
- \[optional\] PHPUnit to execute the test suite

### With Composer

[](#with-composer)

The easiest way to install the calendar is via [composer](http://getcomposer.org/). Create the following `composer.json` file and run the `php composer.phar install` command to install it.

```
{
    "require": {
        "alrik11es/calendar": "0.1.*"
    }
}
```

### No composer

[](#no-composer)

Git clone this repo where you want and include/require all the src folder into your project.

How it works
------------

[](#how-it-works)

Lets get into business. Set up a calendar from today to 6 months into the future:

```
$cal = new \SSC\Calendar();
$structure = $cal->getCalendar();

print_r($structure);
```

The output then is like the next one:

```
Array
(
[2014] => Array
    (
    [type] => year
    [value] => 2014
    [data] =>
    [elements] => Array
        (
        [3] => Array
            (
            [type] => quarter
            [value] => 3
            [data] =>
            [elements] => Array
                (
                [8] => Array
                    (
                    [type] => month
                    [value] => 8
                    [data] =>
                    [elements] => Array
                        (
                        [31] => Array
                            (
                            [type] => week
                            [value] => 31
                            [data] =>
                            [elements] => Array
                                (
                                [1] => Array
                                    (
                                    [type] => day
                                    [value] => 1
                                    [data] =>
                                    [weekday] => 5
                                    )

```

Then you just have to take it and render in your Twig or whatever... (Next one is the spanish way, but you can change to whatever you want)

```

                 -

                        Mon
                        Tue
                        Wed
                        Thu
                        Fra
                        Sun
                        Sat

```

Bam! Calendar!
==============

[](#bam-calendar)

Oh BTW I can give you a Twig example Just for the record :P

```
$cal = new \SSC\Calendar();
$cal->getConfig()->setInterval(new \DateInterval('P12M'));
$cal->day_callback = function($date){
    $day = new \stdClass();
    $day->has_passed = $date->getTimestamp()'Enero', 'Febrero', 'Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'
);
// The week days order. In spanish calendar this is different than in english.
$context['week_days'] = array(1,2,3,4,5,6,0);
// The calendar structure...
$context['cal'] = $cal->getCalendarStructure();
```

Yeah, the Twig file...

```
{% for year in cal %}
    {# You could add here the years #}
    {% for quarter in year.elements %}
        {% for month in quarter.elements %}

                {{ year.value }} - {{ months_es[month.value] }}

                L
                M
                X
                J
                V
                S
                D

            {% for week in month.elements %}

                    {# You could add here the week number #}
                    {% for week_day in week_days%}

                            {% for day in week.elements %}
                                {% if day.weekday == week_day %}

                                        {{ day.value }}

                                {% endif %}
                            {% endfor %}

                    {% endfor %}

            {% endfor %}

        {% endfor %}
    {% endfor %}
{% endfor %}
```

Vue.js
======

[](#vuejs)

With the boom of this kind of libraries just like angular or react. I give you an example of how a render should look like. Obviously you will need to make the API part. But at least this is a good starting point.

```

                    {{ year.value }} - {{ month.value }}

                            Mon
                            Tue
                            Wed
                            Thu
                            Fra
                            Sun
                            Sat

                                        {{ day.value }}

    export default {
        data() {
            return {
                calendar: {},
            }
        },
        methods: {
        },
        mounted() {
            axios.get('/api/calendar').then(response => {
                this.calendar = response.data;
                console.log(this.calendar);
            }).catch(e => {
            });
        }
    }

    .month{
        float: left;
        margin: 10px;
    }

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~202 days

Recently: every ~253 days

Total

6

Last Release

3328d ago

Major Versions

0.1.2 → 1.0.02017-05-19

PHP version history (3 changes)0.1-RC1PHP &gt;=5.3.0

0.1.1PHP &gt;=5.4.0

1.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/249844?v=4)[Marcos](/maintainers/alrik11es)[@alrik11es](https://github.com/alrik11es)

---

Top Contributors

[![alrik11es](https://avatars.githubusercontent.com/u/249844?v=4)](https://github.com/alrik11es "alrik11es (32 commits)")

---

Tags

calendarcomposerphpphp-calendar-generatortwigvuejsgeneratorcalendar

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.3k449.3k30](/packages/tightenco-jigsaw)[infyomlabs/adminlte-templates

AdminLTE templates for InfyOm Laravel Generator

2661.6M7](/packages/infyomlabs-adminlte-templates)[infyomlabs/generator-builder

InfyOm Laravel Generator GUI Builder

132440.8k](/packages/infyomlabs-generator-builder)[anourvalar/office

Generate documents from existing Excel &amp; Word templates | Export tables to Excel (Grids)

23991.5k](/packages/anourvalar-office)[yellowskies/qr-code-bundle

Symfony Barcode &amp; QR Code Generator Bundle with Twig extension

36701.5k](/packages/yellowskies-qr-code-bundle)[tightenco/jigsaw-blog-template

Blog starter template for Jigsaw static site generator by Tighten

9466.1k](/packages/tightenco-jigsaw-blog-template)

PHPackages © 2026

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