定制 coredevelopment/craft-meteo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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_day is 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.icon property 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.php and WeatherService.php.
  • API: All param-building logic is in WeatherService::getWeather. No logic in fetchFromApi.
  • Debugging: Debug logs are written for variable selection and API param-building.

Credits & Support

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 coredevelopment/craft-meteo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-12