{"id":24290776,"url":"https://github.com/andanteproject/period-bundle","last_synced_at":"2025-09-01T20:11:09.109Z","repository":{"id":56947636,"uuid":"355835585","full_name":"andanteproject/period-bundle","owner":"andanteproject","description":"A Symfony Bundle to integrate thephpleague/period into Doctrine and Symfony Form","archived":false,"fork":false,"pushed_at":"2024-01-31T14:23:11.000Z","size":75,"stargazers_count":1,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-18T18:40:00.195Z","etag":null,"topics":["calendar","collection","date","daterange","datetime","datetime-period","datetime-range","doctrine","doctrine-orm","doctrine-type","doctrine-types","interval","period","php","query-builder","range","sequence","symfony","symfony-bundle","symfony-form"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andanteproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-08T09:05:24.000Z","updated_at":"2023-03-13T18:51:33.000Z","dependencies_parsed_at":"2024-11-17T13:44:55.506Z","dependency_job_id":"22012481-b591-49f4-97bf-61f732197084","html_url":"https://github.com/andanteproject/period-bundle","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.2941176470588235,"last_synced_commit":"a4ccd382acf00551119be9309015f82456725126"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/andanteproject/period-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andanteproject%2Fperiod-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andanteproject%2Fperiod-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andanteproject%2Fperiod-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andanteproject%2Fperiod-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andanteproject","download_url":"https://codeload.github.com/andanteproject/period-bundle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andanteproject%2Fperiod-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273183228,"owners_count":25059812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calendar","collection","date","daterange","datetime","datetime-period","datetime-range","doctrine","doctrine-orm","doctrine-type","doctrine-types","interval","period","php","query-builder","range","sequence","symfony","symfony-bundle","symfony-form"],"created_at":"2025-01-16T12:37:44.677Z","updated_at":"2025-09-01T20:11:09.087Z","avatar_url":"https://github.com/andanteproject.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Andante Project Logo](https://github.com/andanteproject/period-bundle/blob/main/andanteproject-logo.png?raw=true)\n\n# Period Bundle\n\n#### Symfony Bundle - [AndanteProject](https://github.com/andanteproject)\n\n[![Latest Version](https://img.shields.io/github/release/andanteproject/period-bundle.svg)](https://github.com/andanteproject/period-bundle/releases)\n![Github actions](https://github.com/andanteproject/period-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)\n![Framework](https://img.shields.io/badge/Symfony-5.4|6.x-informational?Style=flat\u0026logo=symfony)\n![Php7](https://img.shields.io/badge/PHP-%208.x-informational?style=flat\u0026logo=php)\n![PhpStan](https://img.shields.io/badge/PHPStan-Level%208-syccess?style=flat\u0026logo=php)\n\nA Symfony Bundle to integrate [thephpleague/period](https://period.thephpleague.com)\ninto [Doctrine](https://github.com/doctrine/DoctrineBundle) and [Symfony Form](https://github.com/symfony/form).\n\n## Requirements\n\nSymfony 5.4-6.x and PHP 8.0.\n\n## Install\n\nVia [Composer](https://getcomposer.org/):\n\n```bash\n$ composer require andanteproject/period-bundle\n```\n\n## Features\n\n- Persist `Period`, `Duration` and `Sequence` on your DB;\n- Persist `Period` as a JSON field or\n  a [doctrine embeddable object](https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/tutorials/embeddables.html#separating-concerns-using-embeddables)\n  effortless (and it is allowed to be `null`!!).\n- Doctrine DQL functions.\n- Use `Period` in Symfony Forms its Form Type;\n- Works like magic ✨.\n\n## Basic usage\n\nAfter [install](#install), make sure you have the bundle registered in your symfony bundles list (`config/bundles.php`):\n\n```php\nreturn [\n    /// bundles...\n    Andante\\PeriodBundle\\AndantePeriodBundle::class =\u003e ['all' =\u003e true],\n    /// bundles...\n];\n```\n\nThis should have been done automagically if you are using [Symfony Flex](https://flex.symfony.com). Otherwise, just\nregister it by yourself.\n\n## Doctrine Mapping\n\nThe bundle is going to register `period`, `duration` and `sequence` doctrine types to allow you to map `Period`\n, `Duration` and `Sequence` objects to the database.\n\n```php\n\u003c?php\n\nnamespace App\\Entity;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse League\\Period\\Duration;\nuse League\\Period\\Period;\nuse League\\Period\\Sequence;\n\n/**\n * @ORM\\Entity()\n */\nclass Meeting\n{\n    /**\n     * @ORM\\Column(type=\"period\", nullable=true)\n     */\n    private ?Period $period = null;\n    \n    /**\n     * @ORM\\Column(type=\"duration\", nullable=true)\n     */\n    private ?Duration $duration = null;\n    \n    /**\n     * @ORM\\Column(type=\"sequence\", nullable=true)\n     */\n    private ?Sequence $sequence = null;\n}\n```\n\nThese types are going to create a `JSON` field on your database. If you want `Period` to have a column for `startDate`\nand a separate column for `endDate`, check the [Embeddable mapping](#embeddable-period-mapping) down below.\n\n### Embeddable Period Mapping\n\n```php\n\u003c?php\n\nnamespace App\\Entity;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse League\\Period\\Period;\n\n/**\n * @ORM\\Entity()\n */\nclass Meeting\n{\n    /**\n     * @ORM\\Embedded(class=\"League\\Period\\Period\", columnPrefix=\"period_\")\n     */\n    private ?Period $period = null;\n}\n```\n\nThis is going to create 3 different columns on your database like `period_start_date`, `period_end_date`\nand `period_boundary_type` instead of a JSON field. If you want to use some different names for yout mapping, check\nthe [configuration](#configuration-completely-optional) of this bundle. ⚠️ **PLEASE NOTE:** Doctrine v2 does not allow\nEmbedded Classes to be `null`. It's a feature expected in Doctrine v3. **But**, with some magic under the hood, this\nbundle allows you to use `nullable` `Period` anyway. 👍\n\n## Doctrine DQL Functions\n\nNo matter the kind of mapping you are using for your Period ([type](#doctrine-mapping)\nor [embedded](#embeddable-period-mapping)), you can use these DQL functions to access Period properties:\n\n- `PERIOD_START_DATE()` to access `period.startDate`, like `PERIOD_START_DATE(meeting.period)`;\n- `PERIOD_END_DATE()` to access `period.endDate`, like `PERIOD_END_DATE(meeting.period)`;\n- `PERIOD_BOUNDARY_TYPE()` to access `period.boundaryType`, like `PERIOD_BOUNDARY_TYPE(meeting.period)`.\n\n## Period Form Type\n\nUse `Andante\\PeriodBundle\\Form\\PeriodType` as a Form like you are used to. This bundle is shipped with no form theme, so\nit's up to you to build your form theme.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Andante\\PeriodBundle\\Form\\PeriodType;\nuse Symfony\\Component\\Form\\AbstractType;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\n\nclass EventType extends AbstractType\n{\n    public function buildForm(FormBuilderInterface $builder, array $options)\n    {\n        $builder\n            -\u003eadd('name', Type\\TextType::class)\n            -\u003eadd('period', PeriodType::class)\n        ;\n    }\n}\n```\n\n### PeriodType Options\n\n#### default_boundary_type\n\n**type**: `string` **default**: `[)`, allowed values: `[)`, `(]`, `()`, `[]`\nwhich boundary type to be used if none has been selected via `boundary_type_choice`.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'default_boundary_type' =\u003e '()',\n]);\n```\n\n#### boundary_type_choice\n\n**type**: `bool` **default**: `false`\nWhether to include or not a `BoundaryTypeChoiceType` to let the user to choice the BoundaryType. This is `false` by\ndefault. To change which boundary type should be use to create the `Period`, check out `default_boundary_type` option.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'boundary_type_choice' =\u003e true,\n]);\n```\n\n#### start_date_child_name\n\n**type**: `string` **default**: `start`\nHow form child handling `startDate` property should be called.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'start_date_child_name' =\u003e 'custom_start_date_form_child_name',\n]);\n```\n\n#### end_date_child_name\n\n**type**: `string` **default**: `end`\nHow form child handling `endDate` property should be called.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'end_date_child_name' =\u003e 'custom_end_date_form_child_name',\n]);\n```\n\n#### boundary_type_child_name\n\n**type**: `string` **default**: `boundary`\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'boundary_type_child_name' =\u003e 'custom_boundary_type_form_child_name',\n]);\n```\n\nHow form child handling `boundaryType` property should be called.\n\n#### start_date_form_type\n\n**type**: `string` **default**: `Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType`\nWhich form type to be used for `startDate` property. You can replace it with something custom.\n\n```php\nuse App\\Form\\MyDateTimeType;\n\n$builder-\u003eadd('period', PeriodType::class, [\n    'start_date_form_type' =\u003e MyDateTimeType::class,\n]);\n```\n\n#### end_date_form_type\n\n**type**: `string` **default**: `Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType`\nWhich form type to be used for `endDate` property. You can replace it with something custom.\n\n```php\nuse App\\Form\\MyDateTimeType;\n\n$builder-\u003eadd('period', PeriodType::class, [\n    'end_date_form_type' =\u003e MyDateTimeType::class,\n]);\n```\n\n#### start_date_options\n\n**type**: `array` **default**: `[]`\nAdditional options to be used for the *startDate* form child.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'start_date_options' =\u003e [\n        'label' =\u003e 'A different Label',\n        // + whatever option allowed by DateTimeType\n    ],\n]);\n```\n\n#### end_date_options\n\n**type**: `array` **default**: `[]`\nAdditional options to be used for the *endDate* form child.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'end_date_options' =\u003e [\n        'label' =\u003e 'A different Label',\n        // + whatever option allowed by DateTimeType\n    ],\n]);\n```\n\n#### boundary_type_options\n\n**type**: `array` **default**: `[]`\nAdditional options to be used for the *boundaryType* form child.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'boundary_type_options' =\u003e [\n        'label' =\u003e 'A different Label',\n        // + whatever option allowed by Andante\\PeriodBundle\\Form\\BoundaryTypeChoiceType\n    ],\n]);\n```\n\n#### allow_null\n\n**type**: `bool` **default**: `true`\nAdditional options to be used for the *boundaryType* form child.\n\n```php\n$builder-\u003eadd('period', PeriodType::class, [\n    'allow_null' =\u003e false,\n    // Allow to trigger an error when your Period property is not nullable.\n]);\n```\n\n## Configuration (completely optional)\n\nThis bundle is build thinking how to save you time and follow best practices as close as possible.\n\nThis means you can even ignore to have a `andante_period.yml` config file in your application.\n\nHowever, for whatever reason, use the bundle configuration to change most of the behaviors as your needs.\n\n```yaml\nandante_period:\n  doctrine:\n    embedded_period:\n      default:\n        start_date_column_name: start_date # default: null\n          # Column name to be used on database for startDate property. \n        # If set to NULL will use your default doctrine naming strategy\n        end_date_column_name: end_date # default: null\n          # Column name to be used on database for endDate property. \n        # If set to NULL will use your default doctrine naming strategy\n        boundary_type_column_name: boundary_type # default: null\n          # Column name to be used on database for update boundaryType property. \n        # If set to NULL will use your default doctrine naming strategy\n      entity: # You can use per-entity configuration to override default config\n        App\\Entity\\Event:\n          start_date_column_name: starting_at\n          end_date_column_name: ending_at\n        App\\Entity\\Meeting:\n          start_date_column_name: start\n          end_date_column_name: end\n```\n\nBuilt with love ❤️ by [AndanteProject](https://github.com/andanteproject) team.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandanteproject%2Fperiod-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandanteproject%2Fperiod-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandanteproject%2Fperiod-bundle/lists"}