-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,101 @@ | ||
What is LastFmBundle? | ||
============================= | ||
LastFmBundle | ||
============ | ||
[![Latest Stable Version](https://poser.pugx.org/core23/lastfm-bundle/v/stable)](https://packagist.org/packages/core23/lastfm-bundle) | ||
[![Latest Unstable Version](https://poser.pugx.org/core23/lastfm-bundle/v/unstable)](https://packagist.org/packages/core23/lastfm-bundle) | ||
[![License](https://poser.pugx.org/core23/lastfm-bundle/license)](https://packagist.org/packages/core23/lastfm-bundle) | ||
|
||
[![Total Downloads](https://poser.pugx.org/core23/lastfm-bundle/downloads)](https://packagist.org/packages/core23/lastfm-bundle) | ||
[![Monthly Downloads](https://poser.pugx.org/core23/lastfm-bundle/d/monthly)](https://packagist.org/packages/core23/lastfm-bundle) | ||
[![Daily Downloads](https://poser.pugx.org/core23/lastfm-bundle/d/daily)](https://packagist.org/packages/core23/lastfm-bundle) | ||
|
||
[![Build Status](https://travis-ci.org/core23/LastFmBundle.svg)](https://travis-ci.org/core23/LastFmBundle) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/core23/LastFmBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/core23/LastFmBundle) | ||
[![Code Climate](https://codeclimate.com/github/core23/LastFmBundle/badges/gpa.svg)](https://codeclimate.com/github/core23/LastFmBundle) | ||
[![Coverage Status](https://coveralls.io/repos/core23/LastFmBundle/badge.svg)](https://coveralls.io/r/core23/LastFmBundle) | ||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/a1a7ce1f-7508-4022-a5ff-323ce044fff3/mini.png)](https://insight.sensiolabs.com/projects/a1a7ce1f-7508-4022-a5ff-323ce044fff3) | ||
|
||
[![Donate to this project using Flattr](https://img.shields.io/badge/flattr-donate-yellow.svg)](https://flattr.com/profile/core23) | ||
[![Donate to this project using PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://paypal.me/gripp) | ||
|
||
This bundle provides a wrapper for using the [Last.fm API] inside symfony. | ||
|
||
### Installation | ||
## Installation | ||
|
||
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle: | ||
|
||
``` | ||
composer require core23/lastfm-bundle | ||
composer require php-http/guzzle6-adapter # if you want to use Guzzle | ||
``` | ||
|
||
### Enabling the bundle | ||
### Enable the Bundle | ||
|
||
Then, enable the bundle by adding it to the list of registered bundles in `bundles.php` file of your project: | ||
|
||
```php | ||
// app/AppKernel.php | ||
|
||
public function registerBundles() | ||
{ | ||
return array( | ||
// ... | ||
|
||
new Http\HttplugBundle\HttplugBundle(), | ||
new Core23\LastFmBundle\Core23LastFmBundle(), | ||
|
||
// ... | ||
); | ||
} | ||
// config/bundles.php | ||
|
||
return [ | ||
// ... | ||
Http\HttplugBundle\HttplugBundle::class => ['all' => true], | ||
Core23\LastFmBundle\Core23LastFmBundle::class => ['all' => true], | ||
]; | ||
``` | ||
|
||
### Configure the Bundle | ||
|
||
Define the API credentials in your configuration. | ||
|
||
```yml | ||
# config.yml | ||
```yaml | ||
# config/packages/core23_lastfm.yaml | ||
|
||
core23_lastfm: | ||
api: | ||
app_id: %lastfm_api.id% | ||
shared_secret: %lastfm_api.secret% | ||
core23_lastfm: | ||
api: | ||
app_id: "%lastfm_api.id%" | ||
shared_secret: "%lastfm_api.secret%" | ||
``` | ||
## Usage | ||
Define a [HTTPlug] client in your configuration. | ||
```yml | ||
# 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 | ||
```yaml | ||
# config/packages/httplug.yaml | ||
|
||
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 | ||
``` | ||
### API cache | ||
It is recommended to use a cache to reduce the API usage. | ||
```yml | ||
httplug: | ||
plugins: | ||
cache: | ||
cache_pool: 'acme.httplug_cache' | ||
config: | ||
default_ttl: 7200 # Two hours | ||
clients: | ||
default: | ||
plugins: | ||
- httplug.plugin.cache | ||
```yaml | ||
# config/packages/httplug.yaml | ||
|
||
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](LICENSE.md). | ||
## License | ||
This bundle is under the [MIT license](LICENSE.md). | ||
[HTTPlug]: http://docs.php-http.org/en/latest/index.html | ||
[Last.fm API]: http://www.last.fm/api |