Skip to content

Commit

Permalink
Merge pull request #40 from yukoff/feature/adjust-readme
Browse files Browse the repository at this point in the history
Adjust description in README, add badges etc.
  • Loading branch information
yukoff committed Sep 24, 2017
2 parents 952878b + c5e0b31 commit 483b24d
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
## Description
A Laraval Package for use together with the [php-tmdb/api](https://github.com/php-tmdb/api) TMDB Wrapper.
# Laravel Package for TMDB API Wrapper

[![License](https://poser.pugx.org/php-tmdb/laravel/license.png)](https://packagist.org/packages/php-tmdb/laravel)
[![Build Status](https://travis-ci.org/php-tmdb/laravel.svg)](https://travis-ci.org/php-tmdb/laravel)
[![Code Coverage](https://scrutinizer-ci.com/g/php-tmdb/laravel/badges/coverage.png)](https://scrutinizer-ci.com/g/php-tmdb/laravel/)
[![PHP & HHVM](https://php-eye.com/badge/php-tmdb/laravel/tested.svg)](https://php-eye.com/package/php-tmdb/laravel)

A Laravel package that provides easy access to the [php-tmdb/api](https://github.com/php-tmdb/api) TMDB (The Movie Database) API wrapper.
This package comes with a service provider that configures the `Tmdb\Client` and registers it to the IoC container.
Both Laravel 5 and 4 are supported.

[![Latest Stable Version](https://poser.pugx.org/php-tmdb/laravel/v/stable.svg)](https://packagist.org/packages/php-tmdb/laravel)
[![Latest Unstable Version](https://poser.pugx.org/php-tmdb/laravel/v/unstable.svg)](https://packagist.org/packages/php-tmdb/laravel)
[![Dependency Status](https://www.versioneye.com/php/php-tmdb:laravel/badge?style=flat)](https://www.versioneye.com/php/php-tmdb:laravel)
[![Total Downloads](https://poser.pugx.org/php-tmdb/laravel/downloads.svg)](https://packagist.org/packages/php-tmdb/laravel)

## Installation

Install Composer

```
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
```

Add the following to your require block in composer.json config
Add the following to your require block in `composer.json` config

```
"php-tmdb/laravel": "~1.0"
```

or just run the following command in your project:

```
composer require php-tmdb/laravel
```

## Configuration
Add to your `app/config/app.php` (Laravel 4) or 'config/app.php' (Laravel 5) the service provider:

Add to your `app/config/app.php` (Laravel 4) or `config/app.php` (Laravel 5) the service provider:

```php
'providers' => array(
Expand All @@ -31,12 +49,14 @@ Add to your `app/config/app.php` (Laravel 4) or 'config/app.php' (Laravel 5) the

Then publish the configuration file:

#### Laravel 4:
### Laravel 4

```
php artisan config:publish php-tmdb/laravel
```

#### Laravel 5:
### Laravel 5

```
php artisan vendor:publish --provider="Tmdb\Laravel\TmdbServiceProviderLaravel5"
```
Expand All @@ -46,11 +66,14 @@ Next you can modify the generated configuration file `tmdb.php` accordingly.
That's all! Fire away!

## Usage

We can choose to either use the `Tmdb` Facade, or to use dependency injection.

### Facade example

The example below shows how you can use the `Tmdb` facade.
If you don't want to keep adding the `use Tmdb\Laravel\Facades\Tmdb;` statement in your files, then you can also add the facade as an alias in `config/app.php` file.

```php
use Tmdb\Laravel\Facades\Tmdb;

Expand All @@ -65,6 +88,7 @@ class MoviesController {
```

### Dependency injection example

```php
use Tmdb\Repository\MovieRepository;

Expand All @@ -86,8 +110,10 @@ class MoviesController {
```

### Listening to events

We can easily listen to events that are dispatched using the Laravel event dispatcher that we're familiar with.
The following example listens to any request that is made and logs a message.

```php
use Log;
use Event;
Expand All @@ -99,9 +125,11 @@ Event::listen(TmdbEvents::REQUEST, function(RequestEvent $event) {
// do stuff with $event
});
```

In Laravel 5 instead of using the `Event` facade we could also have used the `EventServiceProvider` to register our event listener.

### Image helper

You can easily use the `ImageHelper` by using dependency injection. The following example shows how to show the poster image of the 20 most popular movies.

```php
Expand Down Expand Up @@ -139,8 +167,10 @@ class WelcomeController extends Controller {

}
```

The `Configuration` used by the `Tmdb\Helper\ImageHelper` is automatically loaded by the IoC container.
If you are a Laravel 5.1 user you could also use the blade's `@inject` functionality,

```
@inject('image', 'Tmdb\Helper\ImageHelper')
Expand All @@ -150,7 +180,9 @@ If you are a Laravel 5.1 user you could also use the blade's `@inject` functiona
```

### Registering plugins

Plugins can be registered in a service provider using the `boot()` method.

```php
namespace App\Providers;

Expand Down

0 comments on commit 483b24d

Please sign in to comment.