PHPackages                             andanteproject/period-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. [Database &amp; ORM](/categories/database)
4. /
5. andanteproject/period-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

andanteproject/period-bundle
============================

A Symfony Bundle to integrate thephpleague/period into Doctrine and Symfony Form

2.0.0(4y ago)126.6k3[1 PRs](https://github.com/andanteproject/period-bundle/pulls)MITPHPPHP ^8.0

Since Apr 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/andanteproject/period-bundle)[ Packagist](https://packagist.org/packages/andanteproject/period-bundle)[ RSS](/packages/andanteproject-period-bundle/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (16)Versions (11)Used By (0)

[![Andante Project Logo](https://github.com/andanteproject/period-bundle/raw/main/andanteproject-logo.png?raw=true)](https://github.com/andanteproject/period-bundle/blob/main/andanteproject-logo.png?raw=true)

Period Bundle
=============

[](#period-bundle)

#### Symfony Bundle - [AndanteProject](https://github.com/andanteproject)

[](#symfony-bundle---andanteproject)

[![Latest Version](https://camo.githubusercontent.com/b1506ffa300abea608287824e86f20de6d5d08038f6f7eeae26c0f6716c1cfa0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616e64616e746570726f6a6563742f706572696f642d62756e646c652e737667)](https://github.com/andanteproject/period-bundle/releases)[![Github actions](https://github.com/andanteproject/period-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)](https://github.com/andanteproject/period-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)[![Framework](https://camo.githubusercontent.com/d64bdb612065d56dc1b7022f98c2a7982a856617602db3fe6c6f4390fe38e882/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352e34253743362e782d696e666f726d6174696f6e616c3f5374796c653d666c6174266c6f676f3d73796d666f6e79)](https://camo.githubusercontent.com/d64bdb612065d56dc1b7022f98c2a7982a856617602db3fe6c6f4390fe38e882/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352e34253743362e782d696e666f726d6174696f6e616c3f5374796c653d666c6174266c6f676f3d73796d666f6e79)[![Php7](https://camo.githubusercontent.com/b0a10b0cecd2d004ca1ef8deb262de722a906805d9347775c9c5ce8df31e47cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253230382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/b0a10b0cecd2d004ca1ef8deb262de722a906805d9347775c9c5ce8df31e47cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253230382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)[![PhpStan](https://camo.githubusercontent.com/ecf361cdd6dfc8d69061b1cd65e7414a6e6293da2837adfd795aded2e52cc31a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d737963636573733f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/ecf361cdd6dfc8d69061b1cd65e7414a6e6293da2837adfd795aded2e52cc31a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d737963636573733f7374796c653d666c6174266c6f676f3d706870)

A Symfony Bundle to integrate [thephpleague/period](https://period.thephpleague.com)into [Doctrine](https://github.com/doctrine/DoctrineBundle) and [Symfony Form](https://github.com/symfony/form).

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

[](#requirements)

Symfony 5.4-6.x and PHP 8.0.

Install
-------

[](#install)

Via [Composer](https://getcomposer.org/):

```
$ composer require andanteproject/period-bundle
```

Features
--------

[](#features)

- Persist `Period`, `Duration` and `Sequence` on your DB;
- Persist `Period` as a JSON field or a [doctrine embeddable object](https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/tutorials/embeddables.html#separating-concerns-using-embeddables)effortless (and it is allowed to be `null`!!).
- Doctrine DQL functions.
- Use `Period` in Symfony Forms its Form Type;
- Works like magic ✨.

Basic usage
-----------

[](#basic-usage)

After [install](#install), make sure you have the bundle registered in your symfony bundles list (`config/bundles.php`):

```
return [
    /// bundles...
    Andante\PeriodBundle\AndantePeriodBundle::class => ['all' => true],
    /// bundles...
];
```

This should have been done automagically if you are using [Symfony Flex](https://flex.symfony.com). Otherwise, just register it by yourself.

Doctrine Mapping
----------------

[](#doctrine-mapping)

The bundle is going to register `period`, `duration` and `sequence` doctrine types to allow you to map `Period`, `Duration` and `Sequence` objects to the database.

```
