1. Go to this page and download the library: Download snowmannunu/weather 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/ */
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Psr16Cache;
$redis = new RedisAdapter($redisConnection);
$cache = new Psr16Cache($redis);
$weather = new Weather('your-key');
$weather->withCache($cache, 600); // 缓存 10 分钟
use SnowmanNunu\Weather\Weather;
use SnowmanNunu\Weather\Providers\QWeatherProvider;
$weather = (new Weather(new QWeatherProvider('your-key')))->setLang('en');
$current = $weather->getLiveWeather('Beijing');
echo $current->weather; // Sunny
echo $current->windDirection; // NW