PHP code example of ermakk / laravel-gis-meteo

1. Go to this page and download the library: Download ermakk/laravel-gis-meteo 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/ */

    

ermakk / laravel-gis-meteo example snippets


return [
    'host' => env('GIS_METEO_HOST', 'https://api.gismeteo.net/v4/weather'),
    'auth' => [
        'token' => env('GIS_METEO_AUTH_TOKEN', ''),
    ],
    'cache_ttl' => env('GIS_METEO_CACHE_TTL', 86400), // 24 часа
    'default_city' => env('GIS_METEO_CITY', 'Moscow'),
    'debug_data' => '{}'
];


// Получение погоды для города по умолчанию
$weather = Weather::getWeather();

// Получение погоды для конкретного города
$weather = Weather::setCity('Saint Petersburg')->getWeather();

// Очистка кэша
Weather::clearCache('Moscow');

// Получение данных о погоде
$weather = Weather::getWeather();

// Информация о местоположении
echo $weather->location['name']; // Название города

// Текущая погода
$current = $weather->current;
echo $current->temperature_air; // Температура
echo $current->description;     // Описание

// Направление ветра как DTO
$windDTO = $current->windDirection;
echo $windDTO->direction;        // "северный"
echo $windDTO->shortDirection;   // "С"

// Облачность
$cloudinessDTO = $current->cloudinessLabel;
echo $cloudinessDTO->description; // "Ясно", "Малооблачно" и т.д.

// Тип осадков
$precipitationTypeDTO = $current->precipitationType;
echo $precipitationTypeDTO->type;    // "Дождь", "Снег" и т.д.
echo $precipitationTypeDTO->symbol;  // Эмодзи символ

// Интенсивность осадков
$precipitationIntensityDTO = $current->precipitationIntensity;
echo $precipitationIntensityDTO->intensity;    // "Небольшой дождь/снег"
echo $precipitationIntensityDTO->recommendation; // Рекомендации
bash
php artisan vendor:publish --provider="Ermakk\GisMeteo\Providers\GisMeteoServiceProvider" --tag=config