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

ActiveLibrary[API Development](/categories/api)

serverking/weather
==================

a weather sdk

v1.0.1(9mo ago)17MITPHPCI passing

Since Aug 9Pushed 9mo agoCompare

[ Source](https://github.com/RockyBin/laravel_weather)[ Packagist](https://packagist.org/packages/serverking/weather)[ RSS](/packages/serverking-weather/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

 weather扩展包
===========

[](#-weather扩展包)

 一个laravel weather扩展包

[![Test](https://github.com/RockyBin/laravel_weather/actions/workflows/test.yml/badge.svg)](https://github.com/RockyBin/laravel_weather/actions/workflows/test.yml)[![Latest Stable Version](https://camo.githubusercontent.com/79fe5153579d31cc00fd6afce2fbc97602f6fcecd6e805a69643730d419e2d57/687474703a2f2f706f7365722e707567782e6f72672f7365727665726b696e672f776561746865722f762f737461626c652e737667)](https://packagist.org/packages/serverking/weather) [![Total Downloads](https://camo.githubusercontent.com/ed7d9d34b59784fca09bbab9187c6d894f00c8b1903e4bc59876522df445ee84/687474703a2f2f706f7365722e707567782e6f72672f7365727665726b696e672f776561746865722f646f776e6c6f616473)](https://packagist.org/packages/serverking/weather)[![Latest Unstable Version](https://camo.githubusercontent.com/d0e5dfc8679dc6667cca163618b767adf85b063d115bc40591d90a9c19358b28/68747470733a2f2f706f7365722e707567782e6f72672f7365727665726b696e672f776561746865722f762f756e737461626c652e737667)](https://packagist.org/packages/serverking/weather)[![License](https://camo.githubusercontent.com/68056dd7685d7b11811d5159b5fd0ad20e67ff462a7079e0405ad58b778d7cf7/68747470733a2f2f706f7365722e707567782e6f72672f7365727665726b696e672f776561746865722f6c6963656e73652e737667)](https://packagist.org/packages/serverking/weather)

使用帮助
----

[](#使用帮助)

### 1、首先安装serverking/weather

[](#1首先安装serverkingweather)

```
	composer require serverking/weather -vvv

```

### 2、发布配置文件,运行如下命令后会生成/config/weathers.php配置文件

[](#2发布配置文件运行如下命令后会生成configweathersphp配置文件)

```
php artisan vendor:publish --provider="Serverking\Weather\ServiceProvider" --tag="weathers"

```

### 3、编辑.env文件，添加如下配置

[](#3编辑env文件添加如下配置)

```
WEATHER_API_KEY="高德开放接口中天气预报的key密钥"

```

### 4、调用方式

[](#4调用方式)

```
//注入方式：
public function index(Request $request, Weather $weather, $city){
	return $weather->getWeather($city,'base');
}

//容器方式：
public function index(Request $request, Weather $weather, $city){
    return app('weather')->getWeather($city,'base');
}

```

### 5、添加路由

[](#5添加路由)

```
Route::get('/weather/{city}', [\App\Http\Controllers\WeatherController::class, 'index']);

```

### 6、方问接口进行读取接口

[](#6方问接口进行读取接口)

```
//访问接口：
http://localhost/weather/上海
http://localhost/weather/上海区号

//返回的数据：
{"status":"1","count":"1","info":"OK","infocode":"10000","lives":[{"province":"上海","city":"上海市","adcode":"310000","weather":"多云","temperature":"35","winddirection":"北","windpower":"≤3","humidity":"51","reporttime":"2025-08-08 16:01:17","temperature_float":"35.0","humidity_float":"51.0"}]}

```

License
-------

[](#license)

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance57

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

3

Last Release

282d ago

Major Versions

v0.0.1 → v1.0.02025-08-09

### Community

Maintainers

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

---

Top Contributors

[![RockyBin](https://avatars.githubusercontent.com/u/28974505?v=4)](https://github.com/RockyBin "RockyBin (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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