Search code examples
phpsymfonysilex

Silex - check if user is already in database


I'm new with Silex Framework and I tried to put a validation check when a visitor try to register a new account (about its username) to do not abble to save his request in database. I saw we have Unique Entity in Symfony, but I can't import in Silex. I have been looking for a solution for two days now, but in vain


Solution

  • If you do not use Doctrine to manipulate your databse, you can create your own constraint validator.

    You can use it as a service, so you can inject your database connection into its constructor.