PHPackages                             dyvelop/current-user-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dyvelop/current-user-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

dyvelop/current-user-bundle
===========================

Symfony bundle for fetching the user which is currently logged in

v1.0.0-alpha(9y ago)02.4kMITPHPPHP &gt;=5.5

Since Sep 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dyvelop/current-user-bundle)[ Packagist](https://packagist.org/packages/dyvelop/current-user-bundle)[ RSS](/packages/dyvelop-current-user-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/48f2a2ecab4f4b7ae26c5f820c533210ab873aed3243a7304e693b7f99bf024e/68747470733a2f2f7472617669732d63692e6f72672f647976656c6f702f63757272656e742d757365722d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dyvelop/current-user-bundle)

Dyvelop Current User Bundle
===========================

[](#dyvelop-current-user-bundle)

Symfony bundle to fetch the user which is currently logged in.

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

[](#installation)

### Step 1: Download

[](#step-1-download)

Download via [Composer](https://getcomposer.org/)

```
composer require dyvelop/current-user-bundle
```

### Step 2: Enable Bundle

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

Enable the Bundle in the `app/AppKernel.php` file in your Symfony project:

```
// File: app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Dyvelop\CurrentUserBundle\DyvelopCurrentUserBundle(),
        );

        return $bundles;
    }
}
```

Usage
-----

[](#usage)

### Current User Provider

[](#current-user-provider)

Mainly this bundle implements a service named `dyvelop.current_user.provider` which provides the current user:

```
// fetch current user (the result is NULL when no one is logged in)
$user = $this->container->get('dyvelop.current_user.provider')->getUser();
```

You may use the `CurrentUserAware` interface and `CurrentUserTrait` helper to inject it into any other service.

### Doctrine Annotation

[](#doctrine-annotation)

Secondly, this bundle provides a Doctrine Annotation and Driver to inject the Current User into an entity via lifecycle callbacks:

```
