1. Go to this page and download the library: Download fyennyi/alerts-in-ua-php 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/ */
fyennyi / alerts-in-ua-php example snippets
use Fyennyi\AlertsInUa\Client\AlertsClient;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;
$cache = new Psr16Cache(new FilesystemAdapter()); // Or any other PSR-16 cache
$client = new AlertsClient('your_token', $cache);
use function React\Async\await;
try {
$alerts = await($client->getActiveAlertsAsync());
echo 'Active alerts: ' . count($alerts->getAllAlerts()) . "\n";
foreach ($alerts->getAllAlerts() as $alert) {
echo "{$alert->getAlertType()->value} in {$alert->getLocationTitle()}\n";
}
} catch (\Throwable $e) {
echo 'Error: ' . $e->getMessage() . "\n";
}
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Psr16Cache;
// Example with Filesystem cache
$filesystemCache = new Psr16Cache(new FilesystemAdapter());
$clientWithFilesystemCache = new AlertsClient('your_token', $filesystemCache);
// Example with Redis cache
$redisClient = new \Redis();
$redisClient->connect('localhost', 6379);
$redisCache = new Psr16Cache(new RedisAdapter($redisClient));
$clientWithRedisCache = new AlertsClient('your_token', $redisCache);
// Example with Memcached cache
$memcachedClient = new \Memcached();
$memcachedClient->addServer('localhost', 11211);
$memcachedCache = new Psr16Cache(new \Symfony\Component\Cache\Adapter\MemcachedAdapter($memcachedClient));
$clientWithMemcachedCache = new AlertsClient('your_token', $memcachedCache);
// Basic setup with default cache (if not provided, a no-op cache is used)
$client = new AlertsClient('your_token', $filesystemCache); // Or any other PSR-16 cache
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.