getConnection(); //We only execute this on SQLite databases if ($connection->getDatabasePlatform() instanceof SqlitePlatform) { $native_connection = $connection->getNativeConnection(); //Ensure that the function really exists on the connection, as it is marked as experimental according to PHP documentation if($native_connection instanceof \PDO && method_exists($native_connection, 'sqliteCreateFunction' )) { $native_connection->sqliteCreateFunction('REGEXP', function ($pattern, $value) { return (false !== mb_ereg($pattern, $value)) ? 1 : 0; }); } } } public function getSubscribedEvents() { return[ Events::postConnect ]; } }