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(5y ago)04MITPHP

Since Jul 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fantasyuknow/weather)[ Packagist](https://packagist.org/packages/fantasyuknow/weather)[ RSS](/packages/fantasyuknow-weather/feed)WikiDiscussions master Synced 4d 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 14% 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

2144d 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

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[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)
