ekstremedia/laravel-yr
Laravel package that wraps the Yr weather service (MET Norway), letting you fetch location-based forecasts and weather data in your PHP applications. Clean, simple API with easy configuration and seamless Laravel integration for any project.
Cache::remember() overwrote MET's Expires header with cache_ttl, meaning the app's data was fresher or staler than MET intended, by configuration accident. After this release the cache lifetime is governed by MET's own Expires (floored at 60 s), with cache_ttl / nowcast_cache_ttl as fallback only. Product can now state a defensible promise — "forecast data is no older than MET's stated expiry" — instead of a number someone guessed in a config file.Expires, keeping the last good answer for a day, revalidating with If-Modified-Since, and reusing a 304 body all cut origin traffic while improving data quality — a rare both-directions win.null instead of throwing, and failed requests are never cached. That converts a crash into a UI state you own: empty, last-known, hidden module, or a fallback provider. Someone has to decide which, per surface.Consider it when most of the following hold:
null and failures are never cached, you need a defined behaviour for "no data right now" — banner, stale-with-timestamp, or hide the module.Look elsewhere when:
null on malformed bodies is a deliberate, forgiving contract. If you want exceptions and typed failures to drive retries and alerting, wrap it or pick something stricter.To executives — one paragraph. We can add weather-aware features without a vendor contract, an API key, or a procurement cycle, because the upstream data is free from MET Norway, the same source behind yr.no. This release is a reliability fix, not a feature release: the package now respects the data provider's own cache-expiry instructions instead of overriding them with our settings, keeps serving the last good forecast when the upstream is unreachable, revalidates cheaply instead of re-downloading, and never caches a failed response. Net effect: fresher data, fewer upstream calls, no stale-error lockouts, and no engineering sprint required to adopt it. The trade-off we accept is that a free public service offers no uptime guarantee, so we design the UI to degrade gracefully and we credit MET Norway as their terms require.
To engineering — the ask. Upgrade to v1.2.1 as a routine dependency bump: there are no public API changes, so nothing in our integration code needs to move. What does need a decision is the surrounding behaviour. First, confirm our configured cache_ttl and nowcast_cache_ttl are now understood as fallbacks for when MET omits Expires, not as the primary control — if anyone tuned those values to force refresh behaviour, that tuning is now inert and should be deleted rather than left as misleading config. Second, since a non-JSON body returns null and failures are never cached, verify each call site has an explicit null handler: last-known-value with a timestamp, a hidden module, or a fallback source. Third, confirm the client sends an identifying User-Agent, since that is an upstream expectation and our politeness budget depends on it. Fourth, the 304 path keeps a body for a day and reuses it until the new Expires — worth a cache-key review to make sure no per-user variation is accidentally sharing an entry.
To design and content. Nowcast unlocks short-horizon copy that forecasts cannot support ("rain starting in about 20 minutes"), and sun/moon times unlock daylight-aware scheduling and notification quiet hours. Both need a defined empty state, because the package will hand you null rather than an exception when upstream returns something unexpected. Attribution placement should be settled now, while the surfaces are still being drawn.
What this is not. It is not a weather-alerting system, not a historical archive, and not an SLA-backed vendor relationship. If any of those become requirements, that is a new sourcing conversation, not a config change.
How can I help you explore Laravel packages today?