1. Go to this page and download the library: Download php-tmdb/symfony 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/ */
namespace App;
use Tmdb\Client;
class MovieParser
{
private Client $client;
// Have Symfony auto-wire the client via your constructor
public function __construct(Client $client)
{
$this->client = $client;
}
}
namespace App;
use Tmdb\Model\AbstractModel;
use Tmdb\Repository\MovieRepository;
class MovieParser
{
private MovieRepository $movieRepository;
// Have Symfony auto-wire the repository via your constructor
public function __construct(MovieRepository $movieRepository)
{
$this->movieRepository = $movieRepository;
}
public function findMovie(string $id): AbstractModel
{
// Use the auto-wired repository in any of your methods
return $this->movieRepository->load($id);
}
}