PHPackages                             iidestiny/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. iidestiny/weather

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

iidestiny/weather
=================

Weather acquisition module

1.0.0(7y ago)4121MITPHP

Since Aug 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/iiDestiny/weather)[ Packagist](https://packagist.org/packages/iidestiny/weather)[ RSS](/packages/iidestiny-weather/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (3)Versions (6)Used By (0)

weather
=======

[](#weather)

天气查询组件

[![Build Status](https://camo.githubusercontent.com/10e71c0921d1fcbfb6e93da66cfa1ff8f61f123da2be6c4b0c7e7ed9675c86d4/68747470733a2f2f7472617669732d63692e6f72672f696944657374696e792f776561746865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iiDestiny/weather)[![StyleCI build status](https://camo.githubusercontent.com/74b9e389a355bc07da3fde831fef9eea8f25d28d3d19352b523b1ee7ee63d00d/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134353338363735372f736869656c64)](https://camo.githubusercontent.com/74b9e389a355bc07da3fde831fef9eea8f25d28d3d19352b523b1ee7ee63d00d/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134353338363735372f736869656c64)

安装
--

[](#安装)

```
$ composer require iidestiny/weather -vvv
```

配置
--

[](#配置)

百度开放平台后台获取 AK

使用
--

[](#使用)

```
use IiDestiny\Weather\Weather;

$ak = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';

$weather = new Weather($ak);

// 返回数组格式
$response = $weather->getWeather('深圳');

// 批量获取
$response = $weather->getWeather('深圳|北京');

// 返回 XML 格式
$response = $weather->getWeather('深圳', 'xml');

// 按坐标获取
$response = $weather->getWeather('116.30,39.98', 'json');

// 批量坐标获取
$response = $weather->getWeather('116.43,40.75|120.22,43,33', 'json');

// 自定义坐标格式（coord_type）
$response = $weather->getWeather('116.306411,39.981839', 'json', 'bd09ll');
```

参数说明
----

[](#参数说明)

```
array | string   getWeather(string $location, string $format = 'json', string $coordType = null)
```

> 1. $location 地点，中文或者坐标地址，多个用斗角逗号隔开
> 2. $format 返回格式， json(默认)/xml, json 将会返回数组格式，xml 返回字符串格式。
> 3. $coordType 坐标格式，允许的值为bd09ll、bd09mc、gcj02、wgs84，默认为 gcj02 经纬度坐标。
> 4. 详情说明请参考官方：

Laravel 中使用
-----------

[](#laravel-中使用)

在 `.env` 配置文件中添加配置 (BAIDU\_SN) 可选

```
BAIDU_AK=xxxxx
BAIDU_SN=xxxxx

```

然后方法注入

```
function index(\IiDestiny\Weather\Weather $weather)
{
    return $weather->getWeather('北京');
}
```

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~0 days

Total

2

Last Release

2825d ago

Major Versions

0.0.1 → 1.0.02018-08-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fd752d6e7b89868dc240b306cf02d063276935873b414f9e8ac42a1ef9399fa?d=identicon)[iidestiny](/maintainers/iidestiny)

---

Top Contributors

[![iiDestiny](https://avatars.githubusercontent.com/u/17637481?v=4)](https://github.com/iiDestiny "iiDestiny (25 commits)")

### Embed Badge

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

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

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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