PHPackages                             alphalabs/foundation-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. alphalabs/foundation-bundle

ActiveBundle

alphalabs/foundation-bundle
===========================

Offers a useful base for Symfony2 projects: paginated collection, based service &amp; repositories...

014PHP

Since Jan 7Pushed 12y ago1 watchersCompare

[ Source](https://github.com/AlphaLabs/AlphaLabsFoundationBundle)[ Packagist](https://packagist.org/packages/alphalabs/foundation-bundle)[ RSS](/packages/alphalabs-foundation-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

AlphaLabs Foundation Bundle
===========================

[](#alphalabs-foundation-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/80e40f420dced7bcb21f73697083523641f78406f75726ad939c59281c8326e0/68747470733a2f2f706f7365722e707567782e6f72672f616c7068616c6162732f666f756e646174696f6e2d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/alphalabs/foundation-bundle) [![Latest Unstable Version](https://camo.githubusercontent.com/b78ddfe5da4d0f9e3902531157955302ea7bb13403bfbd72108041457e997830/68747470733a2f2f706f7365722e707567782e6f72672f616c7068616c6162732f666f756e646174696f6e2d62756e646c652f762f756e737461626c652e706e67)](https://packagist.org/packages/alphalabs/foundation-bundle) [![SensioLabsInsight](https://camo.githubusercontent.com/ace3444670d90d2a04fdbefdc8525680ebe4362b9ab48c08e2b3f6004606d2b2/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39633663613032632d646332312d343439632d623133662d6461343938653836386437362f6d696e692e706e67)](https://insight.sensiolabs.com/projects/9c6ca02c-dc21-449c-b13f-da498e868d76)

> A useful base for Symfony2 projects: paginated collection, base service &amp; repositories...

This bundle offers some tools which can be helpful to start on a new Symfony2 project.

For the moment, the bundle gives you the following possibilities:

- **Collection pagination**: Use advantage of paginated content, thanks to the integration of the **PagerFanta** library.
- **Base entity/repository with modification date automatic assignation**: A base entity is provided, and coupled with a base repository which manage a transactional persistence of data and automatic assignation of the creation/update time on the entity. Some exceptions are also provided to easily detect when an error occurred during the persistence/fetch of an entity.
- **Base service**: Handle the pagination manipulation, based on pagination information
- **Pagniation param converter**: If the controller has to deal with pagination, a param converter can be used to retrieve information about the pagination request and inject it directly in the controller method parameter.
- Integrate the **LiipDoctrineCacheBundle** to use cache system in your project

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

[](#installation)

Adds the library in your `composer.json` file:

```
"require": {
    "alphalabs/foundation-bundle": "1.0@dev"
}
```

Don't forget to update your dependencies with `composer update`

Adds the following bundle declaration in your `AppKernel.php` file:

```
public function registerBundles()
    {
        $bundles = array(
            // ...
            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
        );
```

Configuration
-------------

[](#configuration)

You can configure the bundle in your `config.yml` file:

```
alphalabs_foundation:
    pagination:
        items_per_page: 20 # Default number of items per page in paginated collections

# Bundle used to handle automatic insertion of creation/update dates during entity persistence
stof_doctrine_extensions:
    default_locale: en_US
    orm:
        default:
            timestampable: true
```

To configure the caching system, have a look on the **LiipDoctrineCacheBundle** configuration reference.

You can use more Doctrine extensions if you want. In this case, have a look on the **StofDoctrineExtensionBundle** configuration reference.

Usage
-----

[](#usage)

### Base Entity, Repository

[](#base-entity-repository)

#### Entity

[](#entity)

In order to use the automatic date injection in your entities, you have to make then extends the base entity:

```
