定制 pyrrah/openweathermap-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pyrrah/openweathermap-bundle

最新稳定版本:v1.1.0

Composer 安装命令:

composer require pyrrah/openweathermap-bundle

包简介

The simple way to obtain currently weather from OpenWeatherMap for Symfony 5 to 7

README 文档

README

Latest Version on Packagist Software License Total Contributors Total Downloads

This bundle allows you to easily get the weather for a city or a location, via the OpenWeatherMap service.

Requirements

²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

  1. To install this bundle, run the following Composer command :
composer require pyrrah/openweathermap-bundle
  1. 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.

统计信息

  • 总下载量: 254
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固