PHP code example of programmatordev / openweathermap-php-api

1. Go to this page and download the library: Download programmatordev/openweathermap-php-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/ */

    

programmatordev / openweathermap-php-api example snippets


use ProgrammatorDev\OpenWeatherMap\OpenWeatherMap;

// initialize
$api = new OpenWeatherMap('yourapikey');

// get current weather by coordinate (latitude, longitude)
$weather = $api->weather()->getCurrent(50, 50);
// show current temperature
echo $weather->getTemperature();
bash
composer