matthewhallcom / pirate-weather-php
PHP Library for the Pirate Weather API.
v1.1.0
2023-05-10 15:48 UTC
Requires
- php: >=5.6
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.0
- psr/http-message: ^1.0
Requires (Dev)
- illuminate/contracts: ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0
README
PHP Library for the Pirate Weather API.
This is a fork of the dmitry-ivanov/dark-sky-api package.
Usage
-
Install the package via Composer:
composer require matthewhallcom/pirate-weather-php
-
Use the
MatthewHallCom\PirateWeather\PirateWeather
class:use MatthewHallCom\PirateWeather\PirateWeather; $forecast = (new PirateWeather('secret-key')) ->location(46.482, 30.723) ->forecast('daily'); echo $forecast->daily()->summary();
Time Machine Requests
Sometimes it might be useful to get weather for the specified date:
$timeMachine = (new PirateWeather('secret-key')) ->location(46.482, 30.723) ->timeMachine('2020-01-01', 'daily'); echo $timeMachine->daily()->summary();
You can also get weather for multiple dates:
$timeMachine = (new PirateWeather('secret-key')) ->location(46.482, 30.723) ->timeMachine(['2020-01-01', '2020-01-02', '2020-01-03'], 'daily'); echo $timeMachine['2020-01-02']->daily()->summary();
Usage in Laravel
If you're using Laravel <5.5, you have to register service provider and alias by yourself!
-
Publish the config:
php artisan vendor:publish --provider="MatthewHallCom\PirateWeather\Adapters\Laravel\PirateWeatherServiceProvider"
-
Set your secret key in the
.env
file:PIRATE_WEATHER_KEY="Your-Secret-Key"
-
Use the
PirateWeather
facade:use PirateWeather; $forecast = PirateWeather::location(46.482, 30.723) ->forecast('daily'); echo $forecast->daily()->summary();
License
Pirate Weather PHP is open-sourced software licensed under the MIT license.