PHP code example of calliostro / last-fm-client-bundle
1. Go to this page and download the library: Download calliostro/last-fm-client-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/ */
calliostro / last-fm-client-bundle example snippets
// src/Controller/MusicController.php
namespace App\Controller;
use Calliostro\LastFm\LastFmClient;
use Symfony\Component\HttpFoundation\JsonResponse;
class MusicController
{
public function artistInfo(string $artist, LastFmClient $client): JsonResponse
{
$artistInfo = $client->getArtistInfo(artist: $artist);
$topTracks = $client->getArtistTopTracks(artist: $artist, limit: 5);
return new JsonResponse([
'artist' => $artistInfo['artist']['name'],
'bio' => $artistInfo['artist']['bio']['summary'] ?? null,
'topTracks' => $topTracks['toptracks']['track'],
]);
}
}