2017 © Pedro Peláez
 

library openweathermap-bundle

Pyrrah OpenWeatherMap Bundle for Symfony

image

pyrrah/openweathermap-bundle

Pyrrah OpenWeatherMap Bundle for Symfony

  • Wednesday, July 27, 2016
  • by pyrrah
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pyrrah/OpenWeatherMap 🌞

Latest Version on Packagist ![Software License][ico-license] Total Contributors ![Total Downloads][ico-downloads], (*1)

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

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)., (*3)

Installation

  1. To install this bundle, run the following Composer command :, (*4)

    composer require pyrrah/openweathermap-bundle
    
  2. Check configuration file is correctly installed, and edit the default values with yours (Official API docs) :, (*5)

    # 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., (*6)

Configuration

``` yml PyrrahOpenWeatherMapBundle: resource: "@PyrrahOpenWeatherMapBundle/Controller/" type: annotation prefix: /openweathermap/api, (*7)


This exposes the OpenWeatherMap API via <yourdomain>/openweathermap/api. This means that instead of sending a request to http://api.openweathermap.org/ you can now send an unsigned request to <yourdomain>/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 <?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., (*8)

The Versions

27/07 2016

dev-master

9999999-dev https://github.com/pyrrah/OpenWeatherMapBundle

Pyrrah OpenWeatherMap Bundle for Symfony

  Sources   Download

MIT

The Requires

 

bundle symfony open map weather openweathermap pyrrah