PHPackages                             fantasyuknow/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. fantasyuknow/weather

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

fantasyuknow/weather
====================

A weather SDK

0.0.1(6y ago)04MITPHP

Since Jul 1Pushed 6y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

 weather
=========

[](#-weather-)

 基于高德地图的PHP天气信息依赖.

安装
--

[](#安装)

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

配置
--

[](#配置)

你需要去[高德开放平台](https://console.amap.com/dev/index) 注册账号，然后创建应用，获取应用的API Key

使用
--

[](#使用)

```
   use Shenguowei\Weather\Weather;

   $key = 'xxxxxxxxxxx';//API Key

   $w = new Weather($key);

   echo "获取实时天气：\n";

   $response = $w->getWeather('合肥');
   echo json_encode($response,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

   echo "\n获取天气预报：\n";
   $response = $w->getWeather('合肥','forecast');
   echo json_encode($response,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

   echo "\n获取实时天气(XML)\n";
   echo $w->getWeather('合肥','live','XML');

  返回示例：

  {
      "status": "1",
      "count": "1",
      "info": "OK",
      "infocode": "10000",
      "lives": [
          {
              "province": "安徽",
              "city": "合肥市",
              "adcode": "340100",
              "weather": "多云",
              "temperature": "28",
              "winddirection": "北",
              "windpower": "≤3",
              "humidity": "81",
              "reporttime": "2020-07-01 11:24:12"
          }
      ]
  }
```

参数说明
----

[](#参数说明)

```
  $city: 城市名称 比如 '合肥'
  $type：返回内容类型，live实时天气，forecast 预报天气
  $format：输出格式，默认json格式，当设置xml格式时  返回XML格式数据
```

在 Laravel中应用
------------

[](#在-laravel中应用)

在config/services.php 文件中，增加相关配置

```
 "weather"=>[
      "key"=>env("WEATHER_API_KEY")
    ]

```

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity45

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

2192d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28337525?v=4)[shen\_fantasy](/maintainers/fantasyuknow)[@fantasyuknow](https://github.com/fantasyuknow)

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k40](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k120](/packages/oat-sa-tao-core)

PHPackages © 2026

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