PHP code example of mrcnpdlk / weather-api

1. Go to this page and download the library: Download mrcnpdlk/weather-api 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/ */

    

mrcnpdlk / weather-api example snippets



    /**
     * Cache in system files
     */
    $oFilesConfig = new \Phpfastcache\Drivers\Files\Config();
    $oFilesConfig->setPath(sys_get_temp_dir())->setDefaultTtl(60);
    $oInstanceCacheFiles = new \Phpfastcache\Helper\Psr16Adapter('files', $oFilesConfig);
    /**
     * Cache in Redis
     */
    $oRedisConfig = new \Phpfastcache\Drivers\Redis\Config();
    $oRedisConfig
        ->setHost('localhost')
        ->setPort(6379)
        ->setDefaultTtl(60)
        ;
    $oInstanceCacheRedis = new \Phpfastcache\Helper\Psr16Adapter('redis', $oRedisConfig);



$oInstanceLogger = new \Monolog\Logger('name_of_my_logger');
$oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        \Psr\Log\LogLevel::DEBUG
    )
)->pushProcessor(new \Monolog\Processor\PsrLogMessageProcessor());

$oClient = new \mrcnpdlk\Weather\Client();
$oClient
    ->setCacheInstance($oInstanceCacheFiles)
    ->setLoggerInstance($oInstanceLogger)
    ->setAirlyConfig('AIRLY_TOKEN')  // not 

use mrcnpdlk\Weather\NativeModel\GeoPoint;

$oApi->setLocation(new GeoPoint(51.758158,19.544377));

mrcnpdlk\Weather\Model\SunSchedule Object
(
    [sunrise] => 07:46:57
    [sunset] => 15:50:12
    [dayDuration] => 8:03
    [transit] => 11:48:34
    [civilTwilightBegin] => 07:07:27
    [civilTwilightEnd] => 16:29:42
    [nauticalTwilightBegin] => 06:24:41
    [nauticalTwilightEnd] => 17:12:27
    [astronomicalTwilightBegin] => 05:44:05
    [astronomicalTwilightEnd] => 17:53:03
)

mrcnpdlk\Weather\NativeModel\Gios\Station Object
(
    [id] => 10058
    [stationName] => Łódź-Jana Pawła II 15
    [dateStart] => 2015-10-27 00:00:00
    [dateEnd] =>
    [gegrLat] => 51.754613
    [gegrLon] => 19.434925
    [addressStreet] => al. Jana Pawła II 15
    [city] => mrcnpdlk\Weather\NativeModel\Gios\City Object
        (
            [id] => 516
            [name] => Łódź
            [commune] => mrcnpdlk\Weather\NativeModel\Gios\Commune Object
                (
                    [communeName] => Łódź
                    [districtName] => Łódź
                    [provinceName] => ŁÓDZKIE
                )

        )

    [distance] => 2253.495
)