binarythinking / lastfm-bundle
Use Last.fm API in your Symfony 2 application.
Installs: 95
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 7
Forks: 8
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- symfony/framework-bundle: 2.*
This package is not auto-updated.
Last update: 2024-03-11 08:27:33 UTC
README
Symfony 2 Bundle for Last.fm API
This is a Bundle that will help you communicate with Last.fm's API.
Status
The Bundle handles API methods for following contexts (Please see Milestones on github):
- Album
- Artist
- Chart
- Geo
- Library
- Tag
- User
Stay tuned for more coming soon.
Installation
If you're using composer just add:
{ "require": { "binarythinking/lastfm-bundle": "dev-master" } }
If you're using a deps file just add:
[BinaryThinkingLastfmBundle]
target=/bundles/BinaryThinking/LastfmBundle
git=http://github.com/karolsojko/BinaryThinkingLastfmBundle.git
Register the BinaryThinking namespace in autoload.php
<?php $loader->add('BinaryThinking', __DIR__ . '/../vendor/bundles');
And the bundle to AppKernel.php
<?php $bundles = array( // ... new BinaryThinking\LastfmBundle\BinaryThinkingLastfmBundle() );
Configuration
After installing just configure your application with your Last.fm API key and secret.
In your config define those two as:
binary_thinking_lastfm: client_apikey: "my_api_key" client_secret: "my_secret"
Using
In your controller if you want for example a client for the album API context just get the service like this:
<?php $albumClient = $this->get('binary_thinking_lastfm.client.album');
Or you can get the client factory and request for a specific client f.e. album:
<?php $clientFactory = $this->get('binary_thinking_lastfm.client_factory'); $albumClient = $clientFactory->getClient('album', $apiKey, $apiSecret);
Once you have your client you can use on it the methods that are available in the Last.fm API f.e.
<?php // search for an album $albums = $albumClient->search('Sound of perseverance'); // get detailed info on an album $album = $albumClient->getInfo('Cynic', 'Focus');