Giter Club home page Giter Club logo

laravel-forecast's Introduction

Latest Version Software License SensioLabs Insight Quality Score Total Downloads

Laravel 5 compatible package

Laravel version Package version
~4.2 ~1.2
~5.1 ~2.1

Laravel-Forecast

Laravel-forecast provides a service provider and a facade around the Forecast-php wrapper.

Want to use this as a standalone package ? Checkout the Forecast-php API wrapper.

Installation

$ composer require nwidart/laravel-forecast

Add the service provider in app/config/app.php

'providers' => [
	...
	Nwidart\LaravelForecast\LaravelForecastServiceProvider::class
]

Add the Alias provider in app/config/app.php

'aliases' => [
	...
	'Forecast' => Nwidart\LaravelForecast\ForecastFacade::class,
]

Publish the configuration file and add your forecast API key

$ php artisan vendor:publish --provider="Nwidart\LaravelForecast\LaravelForecastServiceProvider"

Usage

Base usage

<?php

Forecast::get('37.8267','-122.423');

// Get the forecast at a given time
Forecast::get(('37.8267','-122.423', '2013-05-06T12:00:00-0400')

Setting global options for every request

In the settings you can add global options that will have used on every request made to Forecast.io. You can add this in the options key of the settings file.

For instance if you want temperature in Celsius:

'options' => [
   'units' => 'si',
],

For more details and all available options check the official documentation.

Alternative method: dependency injection

You can also inject the Nwidart\ForecastPhp\Forecast class into your constructor.

 /**
 * @var \Nwidart\ForecastPhp\Forecast
 */
private $forecast;

public function __construct(\Nwidart\ForecastPhp\Forecast $forecast)
{
    $this->forecast = $forecast;
}

public function doSomething()
{
    $weather = $this->forecast->get($lat, $lon);
}

License (MIT)

laravel-forecast's People

Contributors

nwidart avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.