PHPackages                             lightsuner/carbon-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lightsuner/carbon-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

lightsuner/carbon-bundle
========================

Provide Carbon datetime lib. as annotations param. converter (SensioFrameworkExtraBundle)

2.3(7y ago)15125.4k↓33.3%5[1 issues](https://github.com/lightsuner/CarbonBundle/issues)MITPHP

Since Mar 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/lightsuner/CarbonBundle)[ Packagist](https://packagist.org/packages/lightsuner/carbon-bundle)[ RSS](/packages/lightsuner-carbon-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (9)Used By (0)

Carbon SF2 Bundle
=================

[](#carbon-sf2-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/469b0ebc2ec18aa5a289070cd6e29f65c2aed7eb8e50b15d15a458add916fc59/68747470733a2f2f706f7365722e707567782e6f72672f6c6967687473756e65722f636172626f6e2d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/lightsuner/carbon-bundle)[![Total Downloads](https://camo.githubusercontent.com/5555b0244eec83f79b1a75c26d0896e390535651c2e028f64ab5d5c65e4276f4/68747470733a2f2f706f7365722e707567782e6f72672f6c6967687473756e65722f636172626f6e2d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/lightsuner/carbon-bundle)[![Build Status](https://camo.githubusercontent.com/6a98858fa65ceadf9a35dc8e7900918971910b25f022fccea7c6aeffc08973ab/68747470733a2f2f7472617669732d63692e6f72672f6c6967687473756e65722f436172626f6e42756e646c652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/lightsuner/CarbonBundle)

[Carbon datetime component](https://github.com/briannesbitt/Carbon)
[Symfony2 convertors](http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html)

This bundle provides an opportunity to convert Request and Form data into Carbon objects. Use a ParamConverter to convert Request data:

```
...
use Carbon\Carbon;
...

/**
 * @Route("/blog/archive/{start}/{end}")
 * @ParamConverter("start", options={"format": "Y-m-d"})
 * @ParamConverter("end", options={"format": "Y-m-d"})
 */
public function archiveAction(Carbon $start, Carbon $end)
{
}
```

No code changes are required for converting Form data. Symfony's built-in `DateType` and `DateTimeType` are automatically extended to return Carbon instances.

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

[](#installation)

### Step 1: Download Carbon SF2 Bundle using composer

[](#step-1-download-carbon-sf2-bundle-using-composer)

Add Carbon SF2 Bundle in your composer.json:

#### For `sensio/framework-extra-bundle` `2.x` follow [this link](https://github.com/lightsuner/CarbonBundle/tree/1.x).

[](#for-sensioframework-extra-bundle-2x-follow-this-link)

#### For `sensio/framework-extra-bundle` `3.x`

[](#for-sensioframework-extra-bundle-3x)

```
{
    "require": {
        "lightsuner/carbon-bundle": "2.*"
    }
}
```

Now tell composer to download the bundle by running the command:

```
$ php composer.phar update lightsuner/carbon-bundle
```

Composer will install the bundle to your project's `vendor/lightsuner` directory.

### Step 2: Enable the bundle

[](#step-2-enable-the-bundle)

Enable the bundle in the kernel:

```
