- How do I install tomshaw/laravel-gravatar in a Laravel application?
- Run composer require tomshaw/laravel-gravatar. The package auto-registers its service provider, so there is no publish step, no migrations, and no required environment variables. Defaults are sensible out of the box; publish the config file only if you need to change package-wide behavior.
- Which PHP and Laravel versions does laravel-gravatar support?
- The README currently pins PHP 8.5 and Laravel 13.0, which is ahead of many production stacks on PHP 8.2–8.4 and Laravel 10–12. Laravel 12 support arrived in version 0.2.0, so older tags exist, but adopting one means pinning a stale release. Check the composer.json constraints on the exact tag you plan to use before committing, especially since the package is still pre-1.0.
- How do I render a Gravatar avatar in a Blade template?
- Use the provided Blade directive or the anonymous Blade component and pass Gravatar parameters such as size, default image, and rating by name. For example, an avatar can be rendered at 40 pixels with a retro fallback. Both approaches simply compose a Gravatar URL, so no HTTP call or API key is involved.
- Can I build Gravatar URLs outside Blade, like in a controller or JSON API?
- Yes, the package exposes a facade and a fluent URL builder for use in PHP code. That said, headless and API-first products get limited value because the consuming frontend will usually rebuild the same URL in JavaScript. The correct pattern is to hide it behind your own avatar component or endpoint so you keep a single swap point.
- How do I set a default or fallback avatar such as identicon, monsterid, or retro?
- Pass the Gravatar d parameter through the directive, component, facade, or builder using the package's named parameters. Supported fallbacks include mp, identicon, monsterid, wavatar, retro, robohash, and blank. For production resilience, also add an onerror handler or local initials fallback and allow gravatar.com in your CSP img-src directive.
- Is using Gravatar in production a privacy or GDPR concern?
- Gravatar URLs embed a deterministic hash of the user's email address, so that hash appears in client-visible markup and in referrer logs. Record this in your privacy register and decide whether hashing, proxying, or generated initials as a fallback is appropriate for your jurisdiction. Also note all avatar bytes come from gravatar.com, a third-party CDN that is blocked in some regions.
- What are the alternatives to a Laravel Gravatar package?
- You can build the equivalent in roughly fifteen lines: concatenate the Gravatar base URL with hash('sha256', strtolower(trim($email))) and a query string of options. Other options include Libravatar, local file uploads, or a self-hosted identicon service. Wrapping whichever approach you pick behind your own avatar component keeps the dependency replaceable.
- How do I test Gravatar rendering in my Laravel test suite?
- The README includes a testing section; in practice you should assert the generated URL strings via the facade or builder rather than making network requests. Tests should confirm your size, default, and rating parameters are applied and that the email hash is computed correctly. Keeping assertions on your own wrapper component means your tests survive a switch away from the package.
- Does laravel-gravatar really support Gravatar profiles and QR codes?
- The package description and README table of contents mention profiles and QR codes, but the documented surface area is dominated by the avatar directive and URL builder. Treat profiles and QR code features as unverified until you prove them in a spike. Do not plan product work against undocumented behavior, especially on a 0.x release where APIs can change without notice.
- Is tomshaw/laravel-gravatar actively maintained and safe to depend on?
- It is a single-maintainer package with very low adoption, around one star and no dependents, and version 0.7.0 is still pre-1.0 with no semver guarantee. Release notes are largely Pint style fixes and dependency bumps, which suggests a disciplined hobby project rather than a supported library. Pin an exact version, keep your own avatar component as the swap point, monitor advisories with SCA tooling, and note the MIT license allows forking if needed.