PHPackages                             kikwik/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. kikwik/user-bundle

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

kikwik/user-bundle
==================

A super simple user bundle that provide very basic helpers for symfony 4 user management

v2.0.2(1y ago)1436↓77.8%MITPHPPHP &gt;=8.2.0

Since Dec 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kikwik/user-bundle)[ Packagist](https://packagist.org/packages/kikwik/user-bundle)[ RSS](/packages/kikwik-user-bundle/feed)WikiDiscussions v2 Synced 1w ago

READMEChangelog (10)Dependencies (12)Versions (38)Used By (0)

KikwikUserBundle
================

[](#kikwikuserbundle)

A super simple user bundle that provide very basic helpers for symfony 6.4 and 7.x user management.

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

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require kikwik/user-bundle
```

### Step 2: Enable the Bundle

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

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Kikwik\UserBundle\KikwikUserBundle::class => ['all' => true],
];
```

### Step 3: Creating the User

[](#step-3-creating-the-user)

Run `make:user` command:

```
php bin/console make:user
```

Make your User class extends `Kikwik\UserBundle\Model\BaseUser`:

```
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Kikwik\UserBundle\Model\BaseUser;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
 */
class User extends BaseUser implements UserInterface
{
    //...
}
```

Create the `config/packages/kikwik_user.yaml` config file, set the user class and the unique identifier field name of your user

```
kikwik_user:
    user_class: App\Entity\User
    user_identifier_field: username
    user_email_field: email
    password_min_length: 8
    sender_email: '%env(SENDER_EMAIL)%'
    sender_name: '%env(SENDER_NAME)%'
    enable_admin: true  # default is true
```

and define sender vars in your .env file

```
###> kikwik/user-bundle ###
SENDER_EMAIL=no-reply@example.com
SENDER_NAME="My Company Name"
###< kikwik/user-bundle ###
```

Features
--------

[](#features)

### Disable user access

[](#disable-user-access)

To activate the isEnabled feature set the user\_checker option for your firewall in `config/packages/security.yaml`

```
security:
    firewalls:
        main:
            pattern: ^/
            user_checker: Kikwik\UserBundle\Security\UserChecker
```

### Change password

[](#change-password)

To activate the change and forgot password feature add routes in `config/routes/kikwik_user.yaml`:

```
kikwik_user_bundle_password:
    resource: '@KikwikUserBundle/Resources/config/routes.xml'
    prefix: '/password'
```

The forgot password uses symfony/mailer component, so you must configure it in `.env`

```
MAILER_DSN=sendmail+smtp://localhost

```

This will register the following route:

```
* kikwik_user_password_change
* kikwik_user_password_request
* kikwik_user_password_reset

```

Copy translations file from `vendor/kikwik/user-bundle/src/Resources/translations/KikwikUserBundle.xx.yaml`to `translations/KikwikUserBundle.xx.yaml` and change at least the `request_password.email.sender` value

```
request_password:
    email:
        sender:  'no-reply@my-domain.ltd'
        subject: 'Istruzioni per reimpostare la password'
        content: |

                Ciao {{ username }},
                Abbiamo ricevuto una richiesta per resettare la tua password,
                clicca qui per scegliere una nuova password
                oppure incolla in seguente link nella barra degli indirizzi del browser: {{ reset_url }}

```

Behat
-----

[](#behat)

Require behat and dependencies:

```
$ composer require friends-of-behat/mink-extension friends-of-behat/mink-browserkit-driver friends-of-behat/symfony-extension doctrine/doctrine-fixtures-bundle robertfausk/behat-panther-extension drevops/behat-screenshot --dev
```

Configure behat extensions in `behat.yml.dist`:

```
default:
    suites:
        default:
            contexts:
                - DrevOps\BehatScreenshotExtension\Context\ScreenshotContext
                - App\Tests\Behat\DefaultContext

    extensions:
        FriendsOfBehat\SymfonyExtension:
            bootstrap: tests/bootstrap.php

        Robertfausk\Behat\PantherExtension: ~ # no configuration here

        Behat\MinkExtension:
            default_session: symfony
            symfony: ~
            show_cmd: firefox %s
            javascript_session: panther
            panther:
                options:
                    browser: 'chrome'

        DrevOps\BehatScreenshotExtension:
            dir: '%paths.base%/var/screenshots'
            fail: true
            fail_prefix: 'failed_'
            purge: true
```

Add these lines to the `.env.test` file:

```
PANTHER_NO_HEADLESS=0
DATABASE_URL="mysql://user:password@127.0.0.1:3306/local_db_name"  # same string used in .env.dev
MAILER_DSN=null://null
```

Enable the profiler for the test environment in `config/packages/web_profiler.yaml`:

```
when@test:
    framework:
        profiler: { collect: true }
```

In your `templates/security/login.html.twig` template give `name="login-submit"` to the login submit button:

```

    Sign in

```

Display flashes in your main template:

```
{% for label, messages in app.flashes %}
    {% for message in messages %}

            {{ message|raw }}

    {% endfor %}
{% endfor %}
```

Use the `KikwikUserContextTrait` in your behat context and autowire these services in the constructor:

- `ContainerInterface $driverContainer`
- `EntityManagerInterface $entityManager`
- `UserPasswordHasherInterface $passwordHasher`

Eventually override the `getUserClass` and `getUserIdentifierField` trait functions:

```
declare(strict_types=1);

namespace App\Tests\Behat;

use Behat\Behat\Context\Context;
use Behat\MinkExtension\Context\MinkContext;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManagerInterface;
use Kikwik\UserBundle\Behat\KikwikUserContextTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

/**
 * This context class contains the definitions of the steps used by the demo
 * feature file. Learn how to get started with Behat and BDD on Behat's website.
 *
 * @see http://behat.org/en/latest/quick_start.html
 */
final class DefaultContext extends MinkContext implements Context
{
    use KikwikUserContextTrait;

    /** @var KernelInterface */
    private $kernel;

    /** @var Response|null */
    private $response;

    private ContainerInterface $driverContainer;
    private EntityManagerInterface $entityManager;
    private UserPasswordHasherInterface $passwordHasher;

    public function __construct(KernelInterface $kernel, ContainerInterface $driverContainer, EntityManagerInterface $entityManager, UserPasswordHasherInterface $passwordHasher)
    {
        $this->kernel = $kernel;
        $this->driverContainer = $driverContainer;
        $this->entityManager = $entityManager;
        $this->passwordHasher = $passwordHasher;
    }

    /**
     * @BeforeScenario
     */
    public function clearData()
    {
        $connection = $this->entityManager->getConnection();
        $connection->executeQuery('SET FOREIGN_KEY_CHECKS=0');

        $purger = new ORMPurger($this->entityManager);
        $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
        $purger->purge();

        $connection->executeQuery('SET FOREIGN_KEY_CHECKS=1');
    }

    protected function getUserClass()
    {
        return 'App\Entity\User';
    }

    protected function getUserIdentifierField()
    {
        return 'email';
    }
}
```

Create a feature file to test the reset password in `features/password-request-reset.feature`

Example with `email` as `userIdentifier`:

```
Feature:
    In order to manage private access to site
    As a user
    I want to be able to reset password

    Background:
        Given There is a user "test@example.com" with password "change-me" and "ROLE_USER" roles

    Scenario: Change password should be protected
        When I go to "/password/change"
        Then the response status code should be 200
        And I should not see a "[data-test='change-password-form']" element

    Scenario: Change password
        When I am authenticated as "test@example.com" with password "change-me"
        And I go to "/password/change"
        Then I should see a "[data-test='change-password-form']" element
        When I fill in "change_password_form_newPassword_first" with "myNewPassword"
        And I fill in "change_password_form_newPassword_second" with "myNewPassword"
        And I press "change-password-submit"
        Then I should see a ".alert.alert-success.change_password" element
        When I go to "/logout"
        And I am authenticated as "test@example.com" with password "myNewPassword"
        Then I should not see "Credenziali non valide."

    Scenario: Request password should not be protected
        When I go to "/password/request"
        Then the response status code should be 200
        And I should see a "[data-test='request-password-form']" element

    Scenario: Login page has the forgot password link
        When I go to "/login"
        Then the response status code should be 200
        And I should see a "a[href='/password/request']" element

    Scenario: Request password
      # try a wrog login
        When I go to "/login"
        And I fill in "email" with "test@example.com"
        And I fill in "password" with "mySecretPassword"
        And I press "login-submit"
        Then I should see "Credenziali non valide."
      # request a new password
        When I go to "/password/request"
        Then I should see a "[data-test='request-password-form']" element
        When I fill in "request_password_form_userIdentifier" with "test@example.com"
        And I press "request-password-submit"
        Then I should see an ".alert.alert-success.request_password" element
      # check that email was sent
        And the reset password mail was sent to "test@example.com"
      # reset password
        When I follow the password reset link for user "test@example.com"
        Then I should see a "[data-test='change-password-form']" element
        When I fill in "change_password_form_newPassword_first" with "mySecretPassword"
        And I fill in "change_password_form_newPassword_second" with "mySecretPassword"
        And I press "reset-password-submit"
        Then I should see an ".alert.alert-success.reset_password" element
      # try the login
        When I go to "/login"
        And I fill in "email" with "test@example.com"
        And I fill in "password" with "mySecretPassword"
        And I press "login-submit"
        Then I should not see "Credenziali non valide."

    Scenario: Disabled users can't login
      # try login (should work)
        When I am authenticated as "test@example.com" with password "change-me"
        And user "test@example.com" is disabled
        Then I go to "/logout"
      # try login again (should not work)
        When I go to "/login"
        And I fill in "email" with "test@example.com"
        And I fill in "password" with "change-me"
        And I press "login-submit"
        Then I should see "Credenziali non valide."
```

Example with `username` as `userIdentifier`:

```
Feature:
    In order to manage private access to site
    As a user
    I want to be able to reset password

    Background:
        Given There is a user "testUser" with email "test@example.com" and password "change-me" and "ROLE_USER" roles

    Scenario: Change password should be protected
        When I go to "/password/change"
        Then the response status code should be 200
        And I should not see a "[data-test='change-password-form']" element

    Scenario: Change password
      # auth with old password
        When I am authenticated as "testUser" with password "change-me"
      # change password
        And I go to "/password/change"
        Then I should see a "[data-test='change-password-form']" element
        When I fill in "change_password_form_newPassword_first" with "myNewPassword"
        And I fill in "change_password_form_newPassword_second" with "myNewPassword"
        And I press "change-password-submit"
        Then I should see a ".alert.alert-success.change_password" element
      # logout
        When I go to "/logout"
      # re-auth with new password
        And I am authenticated as "testUser" with password "myNewPassword"
        Then I should not see "Credenziali non valide."

    Scenario: Request password should not be protected
        When I go to "/password/request"
        Then the response status code should be 200
        And I should see a "[data-test='request-password-form']" element

    Scenario: Login page has the forgot password link
        When I go to "/login"
        Then the response status code should be 200
        And I should see a "a[href='/password/request']" element

    Scenario: Request password
      # try a wrog login
        When I go to "/login"
        And I fill in "username" with "testUser"
        And I fill in "password" with "mySecretPassword"
        And I press "login-submit"
        Then I should see "Credenziali non valide."
      # request a new password
        When I go to "/password/request"
        Then I should see a "[data-test='request-password-form']" element
        When I fill in "request_password_form_userIdentifier" with "testUser"
        And I press "request-password-submit"
        Then I should see an ".alert.alert-success.request_password" element
      # check that email was sent
        And the reset password mail was sent to "test@example.com"
      # reset password
        When I follow the password reset link for user "testUser"
        Then I should see a "[data-test='change-password-form']" element
        When I fill in "change_password_form_newPassword_first" with "mySecretPassword"
        And I fill in "change_password_form_newPassword_second" with "mySecretPassword"
        And I press "reset-password-submit"
        Then I should see an ".alert.alert-success.reset_password" element
      # try the login
        When I go to "/login"
        And I fill in "username" with "testUser"
        And I fill in "password" with "mySecretPassword"
        And I press "login-submit"
        Then I should not see "Credenziali non valide."

    Scenario: Disabled users can't login
      # try login (should work)
        When I am authenticated as "testUser" with password "change-me"
        And user "testUser" is disabled
        Then I go to "/logout"
      # try login again (should not work)
        When I go to "/login"
        And I fill in "username" with "test@example.com"
        And I fill in "password" with "change-me"
        And I press "login-submit"
        Then I should see "Credenziali non valide."
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 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 ~49 days

Recently: every ~103 days

Total

37

Last Release

553d ago

Major Versions

v0.x-dev → v1.0.02023-05-21

v1.x-dev → v2.0.02023-12-08

PHP version history (4 changes)v0.0.1PHP ^7.1.3

v0.2.4PHP &gt;=7.1.3

v1.0.0PHP &gt;=7.2.5

v2.0.0PHP &gt;=8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bdd98919c8ee6645e854e72f8c6b76c503e12fd10078fb34ae1668cb2bd6d1a?d=identicon)[kikwik](/maintainers/kikwik)

---

Top Contributors

[![kikwik](https://avatars.githubusercontent.com/u/58590255?v=4)](https://github.com/kikwik "kikwik (83 commits)")

### Embed Badge

![Health badge](/badges/kikwik-user-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[contao/core-bundle

Contao Open Source CMS

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

PHPackages © 2026

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