We’re sorry but this documentation section is outdated. Please have that in mind when trying to use it. You can help us making documentation up to date via Sylius Github. Thank you!

In order to be able to query or sort by some string, we should normalize it. The most common use case for that is canonical email or username. We can then allow for case insensitive users identification by email or username.


User component offers simple canonicalizer which converts given string to lowercase letters. Example usage:

// src/script.php

// update this to the path to the "vendor/"
// directory, relative to this file
require_once __DIR__.'/../vendor/autoload.php';

use Sylius\Component\User\Model\User;
use Sylius\Component\Canonicalizer\Canonicalizer;

$canonicalizer = new Canonicalizer();

$user = new User();

$canonicalEmail = $canonicalizer->canonicalize($user->getEmail());

$user->getEmail(); // returns 'MyEmail@eXample.Com'
$user->getEmailCanonical(); // returns ''