thank-song/weather
Composer 安装命令:
composer require thank-song/weather
包简介
Laravel package for OpenWeather API.
README 文档
README
这是一个用于获取天气数据的 Laravel 扩展包,支持通过城市名称、经纬度等方式调用 OpenWeather 接口。
安装
composer require thank-song/weather
配置发布
可选步骤,发布配置文件以便修改 API Key:
php artisan vendor:publish --tag=config
发布后会在 config/openweather.php 中看到配置项。
需要配置 api_key 项。
参见:OpenWeather API
使用方式
方式一:使用 Facade
use Weather; //通过城市名称获取天气数据 $response = Weather::getByCity('Hangzhou'); //通过经纬度获取天气数据 //$response = Weather::getByCoords(30.2711, 120.1555); //通过城市ID获取天气数据 //$response = Weather::getByCityId(1831806); //通过邮编获取天气数据 //$response = Weather::getByZip(310000); // $response 为一个Response对象,可用方法如下: echo $response->getTemp(); echo $response->getMinTemp(); var_dump($response->getWeather()); var_dump($response->getMain()); //...
方式二:使用容器解析
$weather = app('weather'); $response = $weather::getByCity('Hangzhou');
可用字段
$response->getTemp():当前温度$response->getMinTemp():最低温度$response->getMaxTemp():最高温度$response->getWeather()[0]['description']:天气描述
thank-song/weather 适用场景与选型建议
thank-song/weather 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「weather」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thank-song/weather 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thank-song/weather 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thank-song/weather 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel-forecast provides a service provider and a facade around the Forecast-php wrapper
Add a weather widget to Flarum
Simple weather forecaster for Laravel
Alfabank REST API integration
Unofficial PHP client for aWhere weather API
Anax weather module
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-04