1. Go to this page and download the library: Download evinkuraga/tmdb-laravel 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/ */
evinkuraga / tmdb-laravel example snippets
'providers' => array(
// other service providers
'Tmdb\Laravel\TmdbServiceProvider',
)
use Tmdb\Laravel\Facades\Tmdb; // optional for Laravel ≥5.5
class MoviesController {
function show($id)
{
// returns information of a movie
return Tmdb::getMoviesApi()->getMovie($id);
}
}
use Tmdb\Repository\MovieRepository;
class MoviesController {
private $movies;
function __construct(MovieRepository $movies)
{
$this->movies = $movies;
}
function index()
{
// returns information of a movie
return $this->movies->getPopular();
}
}
use Log;
use Event;
use Tmdb\Event\TmdbEvents;
use Tmdb\Event\RequestEvent;
Event::listen(TmdbEvents::REQUEST, function(RequestEvent $event) {
Log::info("A request was made to TMDB");
// do stuff with $event
});
namespace App\Http\Controllers;
use Tmdb\Helper\ImageHelper;
use Tmdb\Repository\MovieRepository;
class WelcomeController extends Controller {
private $movies;
private $helper;
public function __construct(MovieRepository $movies, ImageHelper $helper)
{
$this->movies = $movies;
$this->helper = $helper;
}
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
$popular = $this->movies->getPopular();
foreach ($popular as $movie)
{
$image = $movie->getPosterImage();
echo ($this->helper->getHtml($image, 'w154', 260, 420));
}
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Tmdb\HttpClient\Plugin\LanguageFilterPlugin;
class TmdbServiceProvider extends ServiceProvider {
/**
* Add a Dutch language filter to the Tmdb client
*
* @return void
*/
public function boot()
{
$plugin = new LanguageFilterPlugin('nl');
$client = $this->app->make('Tmdb\Client');
$client->getHttpClient()->addSubscriber($plugin);
}
/**
* Register services
* @return void
*/
public function register()
{
// register any services that you need
}
}