core23/lastfm-bundle

This bundle provides services for using the last.fm API inside the symfony.

0.1.0 2017-01-11 16:35 UTC

README

Latest Stable Version Latest Unstable Version License

Build Status Scrutinizer Code Quality Code Climate Coverage Status SensioLabsInsight

Donate to this project using Flattr Donate to this project using PayPal

This bundle provides a wrapper for using the Last.fm API inside symfony.

Installation

php composer.phar require core23/lastfm-bundle
php composer.phar require php-http/guzzle6-adapter # if you want to use Guzzle

Enabling the bundle

    // app/AppKernel.php

    public function registerBundles()
    {
        return array(
            // ...
            
            new Http\HttplugBundle\HttplugBundle(),
            new Core23\LastFmBundle\Core23LastFmBundle(),

            // ...
        );
    }

Define the API credentials in your configuration.

    # config.yml

    core23_last_fm:
        api:
            app_id:         %lastfm_api.id%
            shared_secret:  %lastfm_api.secret%

Define a HTTPlug client in your configuration.

    # config.yml
    
    httplug:
        classes:
            client: Http\Adapter\Guzzle6\Client
            message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
            uri_factory: Http\Message\UriFactory\GuzzleUriFactory
            stream_factory: Http\Message\StreamFactory\GuzzleStreamFactory
        clients:
            default:
                # ...
                plugins:
                    - httplug.plugin.redirect # plugin is needed for the webcrawler

It is recommended to use a cache to reduce the API usage.

    httplug:
        plugins:
            cache:
                cache_pool: 'acme.httplug_cache'
                config:
                    default_ttl: 7200 # Two hours
        clients:
            default:
                plugins:
                    - httplug.plugin.cache

This bundle is available under the MIT license.