pyrrah/openweathermap-bundle
Composer 安装命令:
composer require pyrrah/openweathermap-bundle
包简介
The simple way to obtain currently weather from OpenWeatherMap for Symfony 5 to 7
关键字:
README 文档
README
This bundle allows you to easily get the weather for a city or a location, via the OpenWeatherMap service.
Requirements
- Symfony 5.* to 7.*
- API Key (APPID) from OpenWeatherMap²
- Dependencies:
Guzzle
²Please note that the free version of OpenWeatherMap restricts the number of calls per month. Please see documentation). For a large number of calls, I recommend to setting up a cache (not currently managed in this package).
Installation
- To install this bundle, run the following Composer command :
composer require pyrrah/openweathermap-bundle
- Check configuration file is correctly installed, and edit the default values with yours (Official API docs) :
# config/packages/pyrrah_openweathermap.yaml pyrrah_open_weather_map: api_key: your_api_key api_url: https://api.openweathermap.org/data/2.5/ units: metric language: en
Routing (optional)
If you don't want to expose the OpenWeatherMap API via your application, you can skip this section.
Configuration
PyrrahOpenWeatherMapBundle: resource: "@PyrrahOpenWeatherMapBundle/Controller/" type: annotation prefix: /openweathermap/api
This exposes the OpenWeatherMap API via /openweathermap/api. This means that instead of sending a request to http://api.openweathermap.org/ you can now send an unsigned request to /openweathermap/api/*. Make sure you secure this area if you don't want others to be able to post on your behalf.
Usage
After installation and configuration, the service can be directly referenced from within your controllers.
<?php use Pyrrah\OpenWeatherMapBundle\Services\Client; /** @var Client $client */ $client = $this->get('pyrrah.openweathermap.client'); // Retrieve the current weather for Paris, FR $weather = $client->getWeather('Paris,fr'); // Or retrieve the weather using the generic query method $response = $client->query('weather', array('q' => 'Paris,fr')); $weather = json_decode($response->getContent());
Credits
License
This bundle is under the MIT license. For the full copyright and license information please view the License File that was distributed with this source code.
pyrrah/openweathermap-bundle 适用场景与选型建议
pyrrah/openweathermap-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 260 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「map」 「weather」 「open」 「OpenWeatherMap」 「pyrrah」 「weathermap」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pyrrah/openweathermap-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pyrrah/openweathermap-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pyrrah/openweathermap-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Laravel-forecast provides a service provider and a facade around the Forecast-php wrapper
Add a weather widget to Flarum
统计信息
- 总下载量: 260
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-25