forxer/gravatar
forxer/gravatar is a lightweight PHP library for generating Gravatar avatar URLs and retrieving public profile data. It supports configurable sizes, default images, ratings, and hashes, with optional Laravel integration for quick use in Blade views and applications.
Profile::getData() entirely, eliminating a file_get_contents() + unserialize() path on remote data (CWE-502). This closes a deserialization risk that would otherwise have to be explained in a security review. It converts "library may fetch and deserialize untrusted remote payloads" into "library only builds strings" — a meaningfully smaller attack surface and a much easier compliance conversation.//www.gravatar.com → https://gravatar.com host change breaks protocol-relative URL assertions; removal of ProfileFormat/ProfileHasFormat/InvalidProfileFormatException breaks any non-JSON profile usage; read-only properties break direct assignment (->email = , ->initialsName = , ->forceDefault = ); Gravatar::profile()/profiles() no longer take $format.GravatarInterface (extends Stringable) lets us type-hint and fake avatars in tests and swap implementations later. New GravatarExceptionInterface gives a single catch point, so a Gravatar problem degrades gracefully to a fallback avatar instead of a 500. Both reduce the blast radius of a third-party dependency on user-facing pages.Adopt when:
md5()/sha256() + string concatenation scattered across Blade templates and controllers. The 7.0.0 changelog is the argument for the package's existence: Gravatar changed its API version, hashing, and canonical host, and the library absorbed all three.url(), copy(), and a handful of fluent setters.Look elsewhere or defer when:
ProfileFormat enum / ProfileHasFormat trait. There is no replacement; v3 is JSON-only.Adoption checklist for the 7.0.0 bump:
->email =, ->initials =, ->initialsName =, ->forceDefault = — convert to methods.getData(, ProfileFormat, ProfileHasFormat, InvalidProfileFormatException, and any $format argument on profile()/profiles().//www.gravatar.com host strings; plan invalidation, not just a code change.url() calls and catch GravatarExceptionInterface where avatars render.To executives: This is a small, free, open-source dependency that gives users profile avatars without us storing or serving images. The new 7.0.0 release is a maintenance upgrade, not a feature bet: it removes a genuine security weakness (the old version fetched remote data and deserialized it, a known vulnerability class), strengthens the privacy of the email-derived identifiers we send, and catches us up to Gravatar's current API before the old one is retired. The cost is a scoped, mechanical migration whose only real gate is our PHP 8.4 upgrade — which we need on the roadmap anyway. No new spend, less custom code to maintain, and the fallback path keeps avatars rendering if Gravatar is unavailable.
To engineering: Treat 7.0.0 as a semver-major with a hard PHP 8.4 floor. Migration is mostly mechanical — property assignment becomes method calls, $format arguments and the format enum/trait disappear, getData() is gone — but two items need real thought: (1) any MD5-derived hashes or absolute Gravatar URLs we've persisted in the database, cache keys, CDN config, or snapshot tests must be invalidated, not just recompiled; (2) we now own profile fetching, so if we keep that feature it needs Laravel Http, a cache TTL, timeouts, and a graceful fallback. Upside: PHPStan at max with zero errors, a Pest suite covering every class, composer lint/analyse/test/check scripts, GravatarInterface for type-hinting and fakes, and GravatarExceptionInterface for a single catch point around avatar rendering. Recommended stance: adopt as a URL builder only, wrap every call site in a try/catch with an initials fallback, and decline the profile-enrichment feature unless a product requirement justifies building it.
How can I help you explore Laravel packages today?