PHP code example of gmopx / laravel-owm

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

    

gmopx / laravel-owm example snippets


...
use Gmopx\LaravelOWM\LaravelOWM;
...

public function foo()
{
    $lowm = new LaravelOWM();
    $current_weather = $lowm->getCurrentWeather('london');

    dd($current_weather->temperature);
}


    /**
     * Get the current weather of the requested location/city.
     *
     * More info about how to interact with the results:
     *
     * https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/master/Examples/CurrentWeather.php
     *
     * @param $query            (penWeatherMap\CurrentWeather
     */
    public function getCurrentWeather($query, $lang = 'en', $units = 'metric', $cache = false, $time = 600)
    ...


    /**
     * Get the forecast of the requested location/city.
     *
     * More info about how to interact with the results:
     *
     * https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/master/Examples/WeatherForecast.php
     *
     * @param $query            ()
     * @param int $time         (default: 600)
     * @return OpenWeatherMap\WeatherForecast
     */
    public function getWeatherForecast($query, $lang = 'en', $units = 'metric', $days = 5, $cache = false, $time = 600)
    ...


    /**
     * Get the forecast of the requested location/city.
     *
     * More info about how to interact with the results:
     *
     * https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/master/Examples/WeatherHistory.php
     *
     * @param $query            (m string $units     (default: metric) - 'metric' or 'imperial'.
     * @param bool $cache       (default: false)
     * @param int $time         (default: 600)
     * @return OpenWeatherMap\WeatherForecast
     */
    public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $lang = 'en', $units = 'metric', $cache = false, $time = 600)
    ...