https://github.com/lsv/darksky
Wrapper for darksky.net api
https://github.com/lsv/darksky
Last synced: 5 months ago
JSON representation
Wrapper for darksky.net api
- Host: GitHub
- URL: https://github.com/lsv/darksky
- Owner: lsv
- License: mit
- Created: 2019-07-19T17:26:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-20T20:30:52.000Z (almost 7 years ago)
- Last Synced: 2025-08-05T04:11:05.581Z (10 months ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Darksky.net API wrapper
-----------------------
[](https://travis-ci.org/lsv/darksky) [](https://codecov.io/gh/lsv/darksky)
PHP Wrapper for [darksky.net](https://darksky.net) weather api.
Supporting
- [x] Forecast
- [x] TimeMachine
### Install
```
composer require lsv/darksky-php-wrapper
```
### Usage
##### Forecast
```
$client = new Symfony\Component\HttpClient\HttpClient();
$apikey = 'your-api-key';
$latitude = 42.3601;
$longitude = -71.0589;
$forecast = new \Lsv\Darksky\Forecast($apikey, $client);
// Set the optional parameters
// See https://darksky.net/dev/docs#forecast-request for possible parameters
$forecast->exclude(['currently']); // Array of blocks to exclude from the call
$forecast->extendHourly(); // Extend hourly forecast to 148 hours
$forecast->language('da'); // Set the language
$forecast->units('si'); // Change the units
$response = $forecast->call($latitude, $longitude);
// $response is now a \Lsv\Darksky\Response\ForecastResponse object
```
##### Timemachine
```
$client = new Symfony\Component\HttpClient\HttpClient();
$apikey = 'your-api-key';
$latitude = 42.3601;
$longitude = -71.0589;
$time = new \DateTime();
$timemachine = new \Lsv\Darksky\Timemachine($apikey, $client);
// Set the optional parameters
// See https://darksky.net/dev/docs#forecast-request for possible parameters
$timemachine->exclude(['currently']); // Array of blocks to exclude from the call
$timemachine->language('da'); // Set the language
$timemachine->units('si'); // Change the units
$response = $timemachine->call($latitude, $longitude, $time);
// $response is now a \Lsv\Darksky\Response\TimemachineResponse object
```