Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dark Sky Api Laravel Package

dmitry-ivanov/dark-sky-api

View on GitHub
Deep Wiki
Context7

PHP Library for the Dark Sky API

Dark Sky API

StyleCI Build Status Coverage Status

Packagist Version Packagist Stars Packagist Downloads Packagist License

PHP Library for the Dark Sky API.

Dark Sky API - Demo

Usage

  1. Install the package via Composer:

    composer require dmitry-ivanov/dark-sky-api
    
  2. Use the DmitryIvanov\DarkSkyApi\DarkSkyApi class:

    use DmitryIvanov\DarkSkyApi\DarkSkyApi;
    
    $forecast = (new DarkSkyApi('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 DarkSkyApi('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 DarkSkyApi('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!

  1. Publish the config:

    php artisan vendor:publish --provider="DmitryIvanov\DarkSkyApi\Adapters\Laravel\DarkSkyApiServiceProvider"
    
  2. Set your secret key in the .env file:

    DARK_SKY_KEY="Your-Secret-Key"
    
  3. Use the DarkSkyApi facade:

    use DarkSkyApi;
    
    $forecast = DarkSkyApi::location(46.482, 30.723)
        ->forecast('daily');
    
    echo $forecast->daily()->summary();
    

Learn more

You can find more information in my article.

Sponsors

Laravel Idea Material Theme UI Plugin

License

Dark Sky API is open-sourced software licensed under the MIT license.

   

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime