PHP code example of nietonchique / sofascore-api-bundle
1. Go to this page and download the library: Download nietonchique/sofascore-api-bundle 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/ */
nietonchique / sofascore-api-bundle example snippets
use Nietonchique\SofascoreApiBundle\SofascoreClient;
final class ScoresController
{
public function __construct(private readonly SofascoreClient $sofascore)
{
}
public function live(): array
{
return $this->sofascore->match()->liveGames();
}
}
use Nietonchique\SofascoreApiBundle\Exception\ApiBlockedException;
use Nietonchique\SofascoreApiBundle\Exception\NotFoundException;
use Nietonchique\SofascoreApiBundle\Exception\SofascoreExceptionInterface;
try {
$event = $client->match(12436870)->getMatch();
} catch (NotFoundException) {
// no such match
} catch (ApiBlockedException $e) {
// Cloudflare blocked this IP — configure a proxy (see below)
} catch (SofascoreExceptionInterface $e) {
// any other error from the bundle: $e->getMessage()
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.