coredevelopment/craft-meteo
Composer 安装命令:
composer require coredevelopment/craft-meteo
包简介
A headless weather plugin for Craft CMS using the Open-Meteo API.
README 文档
README
A headless weather plugin for Craft CMS using the Open-Meteo API.
Features
- Headless, frontend-agnostic: No frontend output, just robust weather data for your templates or APIs.
- Granular variable selection: Choose which weather variables to fetch for each granularity (current, minutely_15, hourly, daily).
- Weather code to icon/description mapping: Built-in mapping for Weather Icons CSS, including day/night logic.
- Admin panel: Configure API variables, location, units, and cache from a Craft CP section.
- Twig variable: Access weather data anywhere in your templates:
craft.meteo.weather() - Cache management: Weather data is cached for performance; clear cache from the admin panel.
- Extensible: Clean, service-based architecture for easy extension.
Requirements
- Craft CMS 5.8.0+
- PHP 8.2+
Installation
From the Plugin Store:
- Go to the Plugin Store in your project’s Control Panel and search for “meteo”.
- Press “Install”.
With Composer:
composer require coredevelopment/craft-meteo ./craft plugin/install craft-meteo
Configuration & Usage
Settings
- Location: Set latitude, longitude, and timezone.
- Units: Choose temperature, windspeed, precipitation units, and time format.
- Variables: For each granularity (current, minutely_15, hourly, daily), select which weather variables to fetch.
- Cache Duration: Set how long weather data is cached (in seconds).
All settings are managed in the Craft CP under the “Meteo Settings” section.
Twig Usage
Fetch weather data anywhere in your templates:
{% set weather = craft.meteo.weather() %}
{{ dump(weather) }}
- You can pass
lat,lon, or override any settings:
{% set weather = craft.meteo.weather(49.2, -2.1, { forecast_days: 2 }) %}
Data Structure
The returned array mirrors the Open-Meteo API, with additional weather_code_meta for icon/description mapping:
{
"current": {
"weather_code": 2,
"is_day": 1,
"weather_code_meta": {
"description": "Partly cloudy",
"icon": "wi wi-day-cloudy"
},
...
},
"hourly": { ... },
"daily": { ... }
}
- If
is_dayis present, icon will be day/night specific. If not, a generic icon is used.
Weather Icons CSS Integration
To display weather icons in your frontend, include the Weather Icons CSS library in your HTML:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.10/css/weather-icons.min.css">
- See the Weather Icons project for icon previews and documentation.
- The plugin provides the correct icon class in the
weather_code_meta.iconproperty for each weather data point.
Example usage in Twig:
<i class="{{ weather.current.weather_code_meta.icon }}"></i> <span>{{ weather.current.weather_code_meta.description }}</span>
Admin Tools
- Clear Cache: Use the “Clear Cache” button in the Meteo admin panel to force-refresh weather data.
- Settings Persistence: All settings are stored per environment and persist across deployments.
Developer Notes
- Extending: Add new variables or mapping by editing
Settings.phpandWeatherService.php. - API: All param-building logic is in
WeatherService::getWeather. No logic infetchFromApi. - Debugging: Debug logs are written for variable selection and API param-building.
Credits & Support
- Core Development x iPop Digital Collaboration
- Support: info@ipopdigital.com
- MIT License
Changelog
See CHANGELOG.md for release notes.
coredevelopment/craft-meteo 适用场景与选型建议
coredevelopment/craft-meteo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「plugin」 「headless」 「weather」 「forecast」 「craftcms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 coredevelopment/craft-meteo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 coredevelopment/craft-meteo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 coredevelopment/craft-meteo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
This extension provides integration with solr to output content from TYPO3 in JSON format.
Instrument headless chrome/chromium instances from php5.6
Admin Hub for GetCandy. A modern headless e-commerce solution for Laravel PHP framework.
A PSR-7 compatible library for making CRUD API endpoints
A new generation of multi-process async event-driven spider engine based on Workerman
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-12