lsv / darksky-php-wrapper
Wrapper for darksky.net api
v1.0
2019-07-20 20:26 UTC
Requires
- ext-json: *
- symfony/http-client: ^4.3
- symfony/options-resolver: ^4.3
- symfony/property-access: ^4.3
- symfony/property-info: ^4.3
- symfony/serializer: ^4.3
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.7
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2024-11-21 21:01:05 UTC
README
PHP Wrapper for darksky.net weather api.
Supporting
- Forecast
- 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