PHPackages                             thank-song/weather - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. thank-song/weather

ActiveLibrary[API Development](/categories/api)

thank-song/weather
==================

Laravel package for OpenWeather API.

V1.0.0(11mo ago)04MITPHPPHP ^8.0

Since Jun 5Pushed 11mo agoCompare

[ Source](https://github.com/AndyMoxq/open-weather)[ Packagist](https://packagist.org/packages/thank-song/weather)[ RSS](/packages/thank-song-weather/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel Weather 包
=================

[](#laravel-weather-包)

这是一个用于获取天气数据的 Laravel 扩展包，支持通过城市名称、经纬度等方式调用 OpenWeather 接口。

安装
--

[](#安装)

```
composer require thank-song/weather
```

配置发布
----

[](#配置发布)

可选步骤，发布配置文件以便修改 API Key：

```
php artisan vendor:publish --tag=config
```

发布后会在 `config/openweather.php` 中看到配置项。 需要配置 `api_key` 项。 参见：[OpenWeather API](https://openweathermap.org/api)

使用方式
----

[](#使用方式)

### 方式一：使用 Facade

[](#方式一使用-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']`：天气描述

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance51

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

347d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbc5c485ed4609a934dba135f1dcfc1201511d73acc53f896a53ba41caf3e1ae?d=identicon)[AndyMoxq](/maintainers/AndyMoxq)

---

Tags

laravelweather

### Embed Badge

![Health badge](/badges/thank-song-weather/health.svg)

```
[![Health](https://phpackages.com/badges/thank-song-weather/health.svg)](https://phpackages.com/packages/thank-song-weather)
```

###  Alternatives

[rakibdevs/openweather-laravel-api

Laravel package to connect https://openweathermap.org/ to get customized weather data for any location on the globe immediately

7648.2k](/packages/rakibdevs-openweather-laravel-api)[vemcogroup/laravel-weather

Weather package for Laravel to use different providers to get weather info

5525.0k](/packages/vemcogroup-laravel-weather)[gnahotelsolutions/laravel-weather

🌤️ A wrapper around Open Weather Map to get the current weather on a location.

385.3k](/packages/gnahotelsolutions-laravel-weather)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
