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

ActiveLibrary

linsunnyday/weather
===================

A weather SDK

0.0.1(6y ago)04MITPHP

Since Aug 19Pushed 6y ago1 watchersCompare

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

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

 weather
=========

[](#-weather-)

 A weather SDK.

[![Build Status](https://camo.githubusercontent.com/6a56ca8cc5d3790edab3964c06fd7018444ddf3d356099c688ea1ca56f2fdf6b/68747470733a2f2f7472617669732d63692e6f72672f6c696e73756e6e796461792f776561746865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/linsunnyday/weather)[![StyleCI](https://camo.githubusercontent.com/324d332b3faa5439d67ec1ce159871ac2a5411e4803c53c8e9d8fc90a6f1d343/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230333134313736362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/203141766)

Installing
----------

[](#installing)

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

To configure
------------

[](#to-configure)

Before using this extension, you need to go to Golden Open Platform to register your account, then create an application and get the API Key of the application.

Usage
-----

[](#usage)

use Overtrue\\Weather\\Weather;

$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';

$weather = new Weather($key);

Getting Real-Time Weather
-------------------------

[](#getting-real-time-weather)

$response = $weather-&gt;getWeather('深圳'); perhaps, $response = $weather-&gt;getLiveWeather('深圳');

Example：

{ "status": "1", "count": "1", "info": "OK", "infocode": "10000", "lives": \[ { "province": "广东", "city": "深圳市", "adcode": "440300", "weather": "中雨", "temperature": "27", "winddirection": "西南", "windpower": "5", "humidity": "94", "reporttime": "2018-08-21 16:00:00" } \] }

Obtaining the Recent Weather Forecast
-------------------------------------

[](#obtaining-the-recent-weather-forecast)

$response = $weather-&gt;getWeather('深圳', 'all'); perhaps, $response = $weather-&gt;getForecastsWeather('深圳');

Example：

{ "status": "1", "count": "1", "info": "OK", "infocode": "10000", "forecasts": \[ { "city": "深圳市", "adcode": "440300", "province": "广东", "reporttime": "2018-08-21 11:00:00", "casts": \[ { "date": "2018-08-21", "week": "2", "dayweather": "雷阵雨", "nightweather": "雷阵雨", "daytemp": "31", "nighttemp": "26", "daywind": "无风向", "nightwind": "无风向", "daypower": "≤3", "nightpower": "≤3" }, { "date": "2018-08-22", "week": "3", "dayweather": "雷阵雨", "nightweather": "雷阵雨", "daytemp": "32", "nighttemp": "27", "daywind": "无风向", "nightwind": "无风向", "daypower": "≤3", "nightpower": "≤3" }, { "date": "2018-08-23", "week": "4", "dayweather": "雷阵雨", "nightweather": "雷阵雨", "daytemp": "32", "nighttemp": "26", "daywind": "无风向", "nightwind": "无风向", "daypower": "≤3", "nightpower": "≤3" }, { "date": "2018-08-24", "week": "5", "dayweather": "雷阵雨", "nightweather": "雷阵雨", "daytemp": "31", "nighttemp": "26", "daywind": "无风向", "nightwind": "无风向", "daypower": "≤3", "nightpower": "≤3" } \] } \] }

Get the return value in XML format
----------------------------------

[](#get-the-return-value-in-xml-format)

The third parameter is the return value type, JSON and XML are optional, default json:

$response = $weather-&gt;getWeather('深圳', 'all', 'xml');

Example：

 1 1 OK 10000 广东 深圳市 440300 中雨 27 西南 5 94 2018-08-21 16:00:00 Description of parameters
-------------------------

[](#description-of-parameters)

array|string getWeather(string $city, string $type = 'base', string $format = 'json')

City - City name, such as "Shenzhen";

$type - Return content type: base: Return live weather / all: Return forecast weather;

$format - Output data format, default to JSON format, when output is set to "xml", output data in XML format.

Use in Laravel
--------------

[](#use-in-laravel)

The same installation is used in Laravel, and the configuration is written in config/services.php:

```
'weather' => [
    'key' => env('WEATHER_API_KEY'),
],

```

Then configure WEATHER\_API\_KEY in. env:

WEATHER\_API\_KEY=xxxxxxxxxxxxxxxxxxxxx

Linsunnyday\\Weather\\Weather instances can be obtained in two ways:

### Method parameter injection

[](#method-parameter-injection)

```
public function edit(Weather $weather)
{
    $response = $weather->getWeather('深圳');
}

```

### Service name access

[](#service-name-access)

```
public function edit()
{
    $response = app('weather')->getWeather('深圳');
}

```

Reference resources
-------------------

[](#reference-resources)

Golden Open Platform Weather Interface

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/linsunnyday/weather/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/linsunnyday/weather/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

2461d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8135e45dec3dabc4f8bdc1ea42cd20ca11755e26eebc919c5123f8a9f7bfafdd?d=identicon)[linsunnyday](/maintainers/linsunnyday)

---

Top Contributors

[![WeiYouYiLin](https://avatars.githubusercontent.com/u/26057720?v=4)](https://github.com/WeiYouYiLin "WeiYouYiLin (8 commits)")[![linsunnyday](https://avatars.githubusercontent.com/u/54173728?v=4)](https://github.com/linsunnyday "linsunnyday (2 commits)")

### Embed Badge

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

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.

5139.4M286](/packages/laravel-browser-kit-testing)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[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)
