PHP code example of noki / weather-data-provider

1. Go to this page and download the library: Download noki/weather-data-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

noki / weather-data-provider example snippets


php artisan optimize:clear

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043);

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->minutely()->hourly()->daily();

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->minutely()->hourly()->daily(false);

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->minutely()->hourly()->daily(false);

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->temperature()->pressure()->wind()->humidity();

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->imperial();

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::create(1, '52.5202',13.4043)->metric();

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::fromArray([
        'provider_id' => 1,
        'config_location' => [
            'longitude' => '52.5202',
            'latitude' => '13.4043'
        ],
        'config_weather_data' => [
            'temperature' => true,
            'wind' => true,
            'pressure' => false,
            'humidity' => false
        ],
        'config_frequency' => [
            'minutely' => true,
            'hourly' => true,
            'daily' => false
        ],
        'units' => 'imperial'
    ]);

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;

$config = WeatherConfig::fromArray([
        'provider_id' => 1,
        'config_location' => [
            'longitude' => '52.5202',
            'latitude' => '13.4043'
        ],
        'config_weather_data' => [
            'temperature',
            'wind',
            'pressure'
        ],
        'config_frequency' => [
            'minutely',
            'hourly'
        ]
    ]);

use Noki\WeatherDataProvider\WeatherConfig as WeatherConfig;
use Noki\WeatherDataProvider\ProviderGenerator;

$config = WeatherConfig::create(1, '52.5202','13.4043');
$provider = new ProviderGenerator($config);
// Weather data for frequencies that you have choose
$provider->selected_provider->getCustomData(); 
bash
composer dump-autoload