- How do I install torann/laravel-weather in a Laravel app?
- Install it with composer require torann/laravel-weather. On Laravel 5.5 and later the service provider and Weather facade are auto-discovered, so no manual registration is needed. After that, publish the config file with php artisan vendor:publish and add your weather API credentials.
- Which Laravel and PHP versions does laravel-weather support?
- The package targets Laravel 5.5 and newer and relies on the illuminate/support constraints declared in its composer.json. Before adopting it, check those constraints against your exact Laravel and PHP versions, because the README is not always authoritative for a small package. Pin the dependency, for example to 1.0.*, so a surprise composer update cannot change driver behavior underneath you.
- How do I configure API credentials and units in laravel-weather?
- Credentials, the selected driver, and units live in the published config/weather.php file and are read through config(). Never read them via env() in your own code, and run php artisan config:cache locally to verify everything resolves. Treat the published config as your own file and diff it against the vendor version on upgrades.
- Which weather API drivers in torann/laravel-weather still return live data?
- Several bundled drivers are effectively dead or gated: Yahoo Weather is retired, Weather Underground's public API was shut down, and OpenWeatherMap's older endpoints are deprecated in favor of One Call 3.0, which is paid. Expect at most one workable driver depending on your credentials. Run a one-day spike with a real key and dump raw output in tinker to confirm which driver works and what response keys it returns.
- Does laravel-weather support caching weather responses?
- The package advertises caching support, but you should not rely on it as your only guard against quota spend. The safer pattern is to wrap the package adapter in your own cache decorator keyed on driver, units, and rounded coordinates such as two decimal places. Also budget your expected queries per second times cache TTL against the surviving driver's quota and pricing.
- How do I query current conditions or a forecast using the Weather facade?
- You call the Weather facade with a location, such as a city name, and choose between current conditions and forecast methods exposed by the package. Keep those calls out of controllers and Blade templates; put them behind your own WeatherProvider port and map results into your own DTO. That keeps the package disposable and your views free of vendor response shapes.
- What happens when laravel-weather is misconfigured or the provider fails?
- Misconfigured drivers tend to return empty arrays rather than throwing errors, and unit drift between drivers is invisible. Null temperatures can flow into formatting calls like number_format(), so validate and normalize every response on the way in. Add a null object or fallback so an empty forecast renders as unavailable instead of showing 0 degrees.
- Is laravel-weather safe to use in production?
- Treat it as a thin adapter with elevated risk concentrated in maintainer size, upstream API drift, and resilience. The package provides no timeouts, retries, or circuit breaker, so an unresponsive provider can become an unresponsive page unless you add those in your own wrapper. Use it behind a port with a cache decorator, a shallow two-provider fallback chain, and a scheduled contract test that hits the live provider.
- Should I fork laravel-weather or write my own weather client?
- The package surface is small and the license is permissive BSD-2-Clause, so vendoring src/ or forking is roughly a two-hour task if you first document the methods and response keys you depend on. Compare that against writing a roughly 50-line client directly against One Call 3.0. If the one surviving driver is the API you would call directly anyway, the package mostly buys you an afternoon and should be treated as a throwaway spike.
- What are the alternatives to torann/laravel-weather?
- The main alternative is a small custom client built on Laravel's HTTP client, which gives you explicit control over timeouts, retries, and response mapping. That is preferable if your app already has established HTTP client conventions and you do not need the facade abstraction. Either way, define your own WeatherProvider port with a DTO and cache decorator so the underlying vendor remains replaceable.