lsv/windy-php-api
最新稳定版本:v1.0.2
Composer 安装命令:
composer require lsv/windy-php-api
包简介
Windy PHP API client
README 文档
README
A library for interacting with the Windy.com API. This PHP client provides a streamlined way to request and handle weather forecast data from Windy's API.
Features
- Easy integration with Windy.com API
- PSR compliant (HTTP Client, Request, Response, Logger)
- Supports Symfony Validator for request validation
- Includes utilities for working with point forecasts and weather models
- Fully tested with PHPUnit
- Automatic API request and response handling
Requirements
- PHP 8.1 or higher
- A valid Windy API key
- Composer for dependency management
Installation
Install the library via Composer:
composer require lsv/windy-api
Usage
Basic forecast request
<?php require 'vendor/autoload.php'; use Lsv\Windy\Request; use Lsv\Windy\PointForecast\PointForecastRequest; use Lsv\Windy\PointForecast\WeatherModels\WeatherModels; use Lsv\Windy\Shared\Point; // Your Windy API key $apiKey = 'your_api_key_here'; // Create a new request instance $request = new Request($apiKey); // Create a new PointForecastRequest $forecastRequest = new PointForecastRequest( point: new Point(latitude: 55.6761, longitude: 12.5683), // Example coordinates: Copenhagen, Denmark model: WeatherModels::AROME, // Multiple weather models are supported eg WeatherModels::IconEU, WeatherModels::GFS parameters: null, // Optional: Use default parameters accepted by the model multiple parameters are available eg. [WeatherParameter::temp, WeatherParameter::dewpoint] levels: null // Optional: Use default levels [Levels::surface] is default, multiple levels are supported eg [Levels::surface, Levels::h1000] ); // Send the request and get the response try { $response = $request->request($forecastRequest); // $response is an array of Time[] objects // $response[0]->time - DateTimeInterface; // $response[0]->values - array of Value[] objects // $response[0]->values[0]->name - name of the value; // $response[0]->values[0]->unit - string - The value unit // $response[0]->values[0]->value - int|float - the value; } catch (\Throwable $e) { echo 'Error: ' . $e->getMessage(); }
Todo
Point forecast- Map forecast
- Webcams
Development
Code Quality
The project uses PHPStan and PHP CS Fixer for static analysis and coding standards. Run the following command to check and fix code quality:
composer fix
License
This library is licensed under the MIT License. See the LICENSE file for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-13