Download the PHP package snowmannunu/weather without Composer

On this page you can find all versions of the php package snowmannunu/weather. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package weather

🌤 SnowmanNunu/Weather

Tests PHP Version

一个支持多数据源、带缓存、提供标准化 DTO 响应的 PHP 天气 SDK。内置 Web 演示站点,可一键部署为天气查询服务。

在线演示:http://weather.snowmannunu.top/


✨ 特性


📦 安装


🚀 快速开始

基础用法

切换数据源

⚠️ 注意:和风天气的标准版 / 商业版 key 通常绑定私有 API 主机(如 xxx.re.qweatherapi.com), 而不是默认的 devapi.qweather.com。如果遇到 403 Invalid Host,可在构造时传入 host 参数:

host 参数同时支持 http:// 或裸域名(会自动补全 https://)。 也可以在 Nginx / PHP-FPM 中通过环境变量全局配置:

添加缓存

切换语言

SDK 支持中英文输出,通过 setLang() 链式调用即可切换:

支持的 Provider:和风天气(zh/en)、OpenWeatherMap(多语言)、高德地图(返回中文)。 语言信息会自动写入缓存 key,中英文缓存互不干扰。

批量并发查询

一次性获取所有数据(实时天气 + 预报 + 生活指数 + AQI + 预警 + 分钟降水),SDK 内部并行发送请求:

异常处理

SDK 对常见错误做了分类,方便调用方精准处理:


🔌 Laravel 集成

在 config/services.php 中添加:


🌐 Web 演示部署

项目内置 public/ 目录可直接作为站点根目录部署:

环境变量 说明 默认值
WEATHER_KEY Provider API Key 必填
WEATHER_PROVIDER 数据源:amap / qweather / openweathermap amap
WEATHER_LANG 语言:zh / en zh
QWEATHER_API_HOST 和风天气专属 API Host(含 https://) https://devapi.qweather.com

Nginx 配置示例:


🧪 测试


📋 支持的 Provider

Provider 标识 覆盖范围 免费额度
高德地图 amap 中国大陆 5000 次/天
和风天气 qweather 全球 1000 次/天
OpenWeatherMap openweathermap 全球 1000 次/天

各 Provider API 支持对比

接口 高德 AMap 和风 QWeather OpenWeatherMap
实时天气 getLiveWeather ✅ 支持 ✅ 支持 ✅ 支持
天气预报 getForecastsWeather ✅ 支持(3/7 天) ✅ 支持(7 天) ✅ 支持(5 天/3h)
生活指数 getLifeIndices ✅ 支持(运动/洗车/穿衣等) ✅ 支持 ❌ 返回空数组
空气质量 getAirQuality ⚠️ 支持(部分 Key 无权限) ⚠️ 支持(免费版 403) ❌ 返回 null
天气预警 getAlerts ❌ 不支持(返回 []) ⚠️ 支持(免费版 403) ❌ 返回空数组
分钟降水 getMinutelyPrecipitation ❌ 不支持(返回 []) ⚠️ 支持(需经纬度) ❌ 返回空数组

说明

  • 高德:生活指数和 AQI 取决于 Key 是否开通对应权限,SDK 已做容错(报错时返回空,不抛异常)
  • 和风:AQI 和预警接口免费开发版直接 403;分钟降水需传入经纬度坐标,传 LocationID 会报 400
  • OpenWeatherMap:只覆盖了实时天气 + 预报,其余 feature 没有对应免费接口

📄 License

MIT


All versions of weather with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
guzzlehttp/guzzle Version ^7.7
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package snowmannunu/weather contains the following files

Loading the files please wait ...