2017 © Pedro Peláez
 

library open-weather

A very simple wrapper for Open Weather

image

j-crowe/open-weather

A very simple wrapper for Open Weather

  • Tuesday, March 15, 2016
  • by jcrowe206
  • Repository
  • 1 Watchers
  • 3 Stars
  • 16,076 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

OpenWeather PHP Wrapper

Build Status, (*1)

PHP Wrapper for the Open Weather API, (*2)

This library does not require Laravel; however, a Laravel Service Provider is included., (*3)

Installation

Install using composer:, (*4)

"require": {
    "j-crowe/open-weather": "1.2"
}

or via CLI, (*5)

composer require j-crowe/open-weather 1.2

Configuration

There are 3 required configurations:, (*6)

First, the app_id - an environment variable named 'OPENWEATHER_APPID' that must be set in your application, (*7)

Please see here to get one, (*8)

The other two - the Base URL and Default Guzzle Options., (*9)

Please see here for possible options, (*10)

Usage Without Laravel

See below for sample initialization code:, (*11)

<?php

include_once 'vendor/autoload.php';

use JCrowe\OpenWeather\OpenWeather;

// Note the configs that are required. Guzzle Opts are default options for Guzzle
$baseUrl = 'http://api.openweathermap.org';
$guzzleOpts = array(
    'timeout' => 3,
    'connect_timeout' => 3
);
$appId = 'abcdefghijklmnop1234567890';

$openWeather = OpenWeather::getInstance($guzzleOpts, $baseUrl, $appId);

$response = $openWeather->getByCityName('los angeles');

if($response->isValid()) {
    print_r($response->getWeatherData());
}

?>

Usage With Laravel

In config/app.php, add the following to the service providers array., (*12)

array(
    ...
    'JCrowe\OpenWeather\Providers\OpenWeatherServiceProvider',
)

Then add the following to the aliases array., (*13)

'OpenWeather' => 'JCrowe\OpenWeather\Facades\OpenWeather'

Publish the configs using php artisan config:publish j-crowe/open-weather, which should include the default configuration, which should include the default configuration., (*14)

The Versions

15/03 2016

dev-master

9999999-dev

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe

15/03 2016

v1.2.0

1.2.0.0

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe

05/10 2015

1.1.0

1.1.0.0

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe

20/11 2014

1.0.2

1.0.2.0

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe

20/11 2014

1.0.1

1.0.1.0

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe

20/11 2014

1.0.0

1.0.0.0

A very simple wrapper for Open Weather

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jonathan Crowe