Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Unique Gmail Address Laravel Package

imliam/php-unique-gmail-address

A small PHP utility for generating unique Gmail addresses from an existing Gmail account. It adds plus-tag aliases so each address looks different but still delivers to the same inbox, handy for testing, signups, and avoiding duplicate-email checks.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install with composer require imliam/php-unique-gmail-address. It's framework-agnostic plain PHP, so it drops into Laravel fine but doesn't ship a service provider or facade — you call it directly.
  • Look first at src/UniqueGmailAddress.php and the README. The package is intentionally tiny: one class exposing a static normalizer. There is no config file to publish.
  • The behavior it encodes: Gmail ignores dots in the local part and ignores everything after a +. So [email protected], [email protected], and [email protected] all resolve to the same inbox.
use ImLiam\UniqueGmailAddress\UniqueGmailAddress;

UniqueGmailAddress::getUniqueGmailAddress('[email protected]');
// => '[email protected]'
  • First use case: stop the same person from registering twice. Normalize the submitted address, then check your users table against the canonical form rather than the raw string.

Implementation Patterns

Store both forms. Keep the address the user typed (for display, receipts, and password-reset links) and the canonical form for uniqueness and lookups:

Schema::table('users', function (Blueprint $table) {
    $table->string('email_normalized')->nullable()->unique()->after('email');
});

Backfill existing rows before adding the unique index, otherwise duplicate Gmail accounts already in the table will make the migration fail.

Normalize on registration and on login. The same helper should feed both paths:

$normalized = UniqueGmailAddress::getUniqueGmailAddress($request->email);

User::create([
    'email'            => $request->email,          // display
    'email_normalized' => $normalized,              // unique key
    'password'         => Hash::make($request->password),
]);
$user = User::where('email_normalized', $normalized)->first();

Wrap it once. Create app/Support/EmailNormalizer.php that delegates to the package. That gives you one seam to swap in a multi-provider normalizer later, and insulates you if the package's static method name ever moves:

public static function normalize(string $email): string
{
    return UniqueGmailAddress::getUniqueGmailAddress($email);
}

Validation rules. Because Rule::unique compares against raw input, either normalize in prepareForValidation() of a FormRequest, or use a closure rule that compares the normalized column against the normalized input. The latter is less surprising.

Bulk/list deduplication. For imports and invite lists, map over the input and unique() on the normalized value while retaining the original for sending:

$deduped = collect($emails)
    ->keyBy(fn ($e) => EmailNormalizer::normalize($e))
    ->values();

Extension point: other providers. The package only knows Gmail semantics. If you also need Outlook aliases, Fastmail + handling, or Proton, compose it — call the package for gmail.com/googlemail.com and fall back to your own logic for everything else inside your EmailNormalizer.

Gotchas and Tips

  • Non-Gmail domains must pass through untouched. Dots are significant for almost every other provider; normalizing them away would merge unrelated accounts. Verify the package leaves other domains alone, and don't assume it maps googlemail.com → gmail.com — test it explicitly, since those are the same mailbox at Google.
  • Keep the original. If you only store the canonical form, users won't recognize their own account and reset emails may look wrong. Store both columns and index only the canonical one.
  • Case handling. Gmail treats the local part case-insensitively even though the RFC doesn't. Confirm the package lowercases; if not, lowercase the whole string yourself before normalizing.
  • Don't over-trust it. This is a deduplication tool, not verification. A canonicalized address still tells you nothing about deliverability or ownership — keep your existing email-verification flow.
  • Empty local part. [email protected] and [email protected] are not valid Gmail addresses. Strip dots/plus first, then re-run your standard email validation on the result so you don't persist an empty local part.
  • Testing. Add unit tests asserting your stored email_normalized for a handful of variants (dots, plus, dots+plus, uppercase, googlemail.com, not-gmail.com). This doubles as a regression guard if the package's normalization changes between releases — it's on a 0.x-style cadence and the last release was recent.
  • Debugging duplicates. When a duplicate slips through, compare the raw values first: it's almost always a path that bypassed your wrapper (an admin panel, a seeder, an API endpoint) and wrote email_normalized without normalizing, or a nullable column where the unique index silently allows repeated NULLs.
  • Exact method signature. The package exposes a single static entry point; check the README for the precise name in the version you install, and rely on your EmailNormalizer wrapper everywhere else so any rename is a one-line change.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource