Download the PHP package ekstremedia/laravel-yr without Composer
On this page you can find all versions of the php package ekstremedia/laravel-yr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ekstremedia/laravel-yr
More information about ekstremedia/laravel-yr
Files in ekstremedia/laravel-yr
Package laravel-yr
Short Description A lightweight Laravel package for integrating weather data from Yr (api.met.no)
License MIT
Homepage https://github.com/ekstremedia/laravel-yr
Informations about the package laravel-yr
Laravel Yr Weather
Get weather data from Yr (MET Norway) in your Laravel apps. Simple, cached, and ready to use.
Installation
Publish the config:
Add your details to .env:
Note: MET Norway requires you to identify your app with contact info.
Quick Start
See it in action
Visit the interactive demo page:
The demo page features:
- Live weather display for any location
- Location search - Search by city name (e.g., "Oslo, Norway")
- Manual coordinates - Enter latitude/longitude directly
- Real-time updates - Weather components update as you change locations
Search by location:
Use specific coordinates:
To disable the demo route, add to your .env:
Get weather by coordinates
Get weather by address
Get forecast
Get sunrise/sunset data
Get moon phase data
Response Example
Usage
Using the Weather Helper (Recommended)
The easiest way to use this package is through the WeatherHelper service:
Using API Routes
The package automatically registers API routes (fully configurable):
Customize API routes in your .env:
With the above config, routes become:
/weather/now(current weather)/weather/predictions(forecast)/weather/sunrise(sun data)/weather/moonphase(moon data)
Using Services Directly
In Blade templates
Current weather:
5-Day Forecast:
Sunrise/Sunset:
Moon Phase:
In JavaScript
Available Data
Weather Data
Each weather response includes:
- Temperature (actual and feels-like)
- Wind (speed, direction, gusts)
- Humidity and pressure
- Cloud coverage
- Precipitation
- UV index
- Weather symbol/icon code
Sun Data
Sunrise/sunset responses include:
- Sunrise and sunset times with azimuth
- Solar noon and solar midnight
- Sun elevation angles
- Daylight duration (hours and minutes)
Moon Data
Moon phase responses include:
- Moon phase (degrees and name: New Moon, Waxing Crescent, etc.)
- Moon phase emoji visualization
- Moonrise and moonset times with azimuth
- High moon and low moon times with elevation
Configuration
The config file (config/yr.php) has these settings:
Weather data is automatically cached to avoid hitting the API too often.
How caching works
The package intelligently caches all API requests:
- Weather data: Cached by coordinates and parameters until the
Expirestime MET Norway sends with each answer (forecasts typically expire within the hour).cache_ttlis only the fallback when MET sends noExpires. Sun and moon data follow the same rule. A failed request is never cached. - Geocoding: Address lookups are cached for 7 days to minimize requests to the geocoding service.
- Conditional requests: Once an answer has expired, the next request sends
If-Modified-Since; a304 Not Modifiedreuses the cached body and keeps it until the newExpires. The last good answer is kept for a day for this.
All GET endpoints (/api/weather/current and /api/weather/forecast) benefit from this caching layer, ensuring fast responses while respecting API rate limits.
Customization
Want to change how the weather cards look? Publish the views:
Then edit resources/views/vendor/laravel-yr/components/weather-card.blade.php.
Want to use local weather icons? Publish the symbols:
This copies 83 weather symbol SVGs to public/vendor/laravel-yr/symbols.
Licensing and Attribution
Weather Data
All weather data is provided by The Norwegian Meteorological Institute (MET Norway) and is licensed under:
- Norwegian Licence for Open Government Data (NLOD) 2.0
- Creative Commons 4.0 BY International (CC BY 4.0)
When using this package, you must provide appropriate credit to MET Norway as the source of the weather data. The package components automatically include the required attribution.
Required Attribution: "Weather data from The Norwegian Meteorological Institute (MET Norway)"
For more details, see MET Norway's Licensing and Crediting Policy.
Weather Icons
The weather symbol SVG files are licensed under the MIT License. Copyright (c) 2015-2017 Yr.no.
Package Code
This Laravel package code is licensed under the MIT License.
Credits
- Weather data: The Norwegian Meteorological Institute (MET Norway)
- Weather icons: Yr.no
- Package developed for easy integration of Norwegian weather data in Laravel applications
License
MIT License - See LICENSE file for details
Note: This package's MIT license applies only to the package code itself. Weather data and icons have their own licenses as stated above.
All versions of laravel-yr with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.0