PHPackages                             setono/client-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. setono/client-bundle

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

setono/client-bundle
====================

Integrate the client library into your Symfony application

v1.1.0(1y ago)115.5k↓41.7%1[1 issues](https://github.com/Setono/client-bundle/issues)4MITPHPPHP &gt;=8.1CI passing

Since Apr 9Pushed 1y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (21)Versions (11)Used By (4)

Track users between visits in Symfony
=====================================

[](#track-users-between-visits-in-symfony)

[![Latest Version](https://camo.githubusercontent.com/5d4ff0e82144381527ebd3c388b2a5bb4a0221dfee7ad2945e4ff11148a06eeb/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f636c69656e742d62756e646c652f762f737461626c65)](https://packagist.org/packages/setono/client-bundle)[![Software License](https://camo.githubusercontent.com/195dc4050694ccf36c4d758df89db937f676d80169a167af03d2c24aae42d6bc/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f636c69656e742d62756e646c652f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/client-bundle/workflows/build/badge.svg)](https://github.com/Setono/client-bundle/actions)[![Code Coverage](https://camo.githubusercontent.com/310b3836965f541f5237c4f2574e9aef1d0603a643c221b60783c81d00ddc0c7/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f636c69656e742d62756e646c652f6272616e63682f62616467652e737667)](https://codecov.io/gh/Setono/client-bundle)

This bundle allows you to track your users between visits and add custom metadata to each user.

Out of the box, the bundle will store a cookie named `setono_client_id` which contains the client id, a created timestamp and a last seen timestamp.

It will also create a new table with metadata for each client id. The metadata functionality is lazy loaded, so if you don't use it, it will not query the database.

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

[](#installation)

To install this bundle, simply run:

```
composer require setono/client-bundle
```

### Migrate your database

[](#migrate-your-database)

```
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
```

Usage
-----

[](#usage)

### Access the `Client` object along with some metadata

[](#access-the-client-object-along-with-some-metadata)

```
use Setono\Client\Client;

final class YourController extends AbstractController
{
    public function index(Client $client): Response
    {
        return $this->render('your_template.html.twig', [
            'id' => $client->id,
            'some_metadata' => $client->metadata->get('some_metadata_key'), // this call will initialize the metadata object from the database
        ]);
    }
}
```

### Set some metadata in an event subscriber

[](#set-some-metadata-in-an-event-subscriber)

```
use Setono\Client\Client;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Setono\ClientBundle\Context\ClientContextInterface;

final class YourEventSubscriber implements EventSubscriberInterface
{
    public function __construct(private readonly ClientContextInterface $clientContext)
    {}

    public static function getSubscribedEvents(): array
    {
        return [
            KernelEvents::REQUEST => 'setMetadata',
        ];
    }

    public function setMetadata(RequestEvent $event): void
    {
        if (!$event->isMainRequest() || !$event->getRequest()->query->has('gclid')) {
            return;
        }

        $this->clientContext->getClient()->metadata->set('google_click_id', $event->getRequest()->query->get('gclid'));
    }
}
```

### Access the cookie

[](#access-the-cookie)

The client id is saved in a cookie named `setono_client_id` (by default). The cookie also holds other information, like the first and last time the client was seen. You can access the cookie like this:

```
use Setono\ClientBundle\CookieProvider\CookieProviderInterface;

final class YourService
{
    public function __construct(private readonly CookieProviderInterface $cookieProvider)
    {}

    public function call(): void
    {
        $cookie = $this->cookieProvider->getCookie();
        if(null === $cookie) {
            return; // no cookie found
        }

        $clientId = $cookie->clientId; // the client id
        $created = $cookie->firstSeenAt; // the timestamp when the client was first seen
        $lastSeen = $cookie->lastSeenAt; // the timestamp when the client was last seen
    }
}
```

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

[](#configuration)

Here's the configuration you are able to do:

```
setono_client:
    cookie:
        # The name of the cookie that holds the client id. NOTICE that if you change this value, all clients with a cookie with the old name will be considered new clients
        name: setono_client_id

        # The expiration of the cookie. This is a string that can be parsed by strtotime
        expiration: '+365 days'

    # If you want to use a custom metadata class, you can specify it here
    metadata_class: Setono\ClientBundle\Entity\Metadata
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance25

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~75 days

Total

10

Last Release

432d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2412177?v=4)[Joachim Løvgaard](/maintainers/loevgaard)[@loevgaard](https://github.com/loevgaard)

---

Top Contributors

[![loevgaard](https://avatars.githubusercontent.com/u/2412177?v=4)](https://github.com/loevgaard "loevgaard (59 commits)")

---

Tags

phpsymfonysymfony-bundletracking

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/setono-client-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/setono-client-bundle/health.svg)](https://phpackages.com/packages/setono-client-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
