{"id":22834756,"url":"https://github.com/php-tmdb/symfony","last_synced_at":"2025-08-21T20:33:31.822Z","repository":{"id":14146483,"uuid":"16852161","full_name":"php-tmdb/symfony","owner":"php-tmdb","description":"Symfony 4,5 and 6 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.","archived":false,"fork":false,"pushed_at":"2023-03-19T20:49:37.000Z","size":113,"stargazers_count":35,"open_issues_count":1,"forks_count":27,"subscribers_count":7,"default_branch":"5.0","last_synced_at":"2024-12-12T22:07:22.512Z","etag":null,"topics":["php-tmdb","psr-12","psr-17","psr-18","psr-3","psr-6","psr-7","symfony","symfony-bundle","tmdb"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-tmdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-14T23:12:24.000Z","updated_at":"2024-03-22T12:52:55.000Z","dependencies_parsed_at":"2024-06-19T09:17:03.928Z","dependency_job_id":null,"html_url":"https://github.com/php-tmdb/symfony","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Fsymfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Fsymfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Fsymfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Fsymfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-tmdb","download_url":"https://codeload.github.com/php-tmdb/symfony/tar.gz/refs/heads/5.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532451,"owners_count":18240792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php-tmdb","psr-12","psr-17","psr-18","psr-3","psr-6","psr-7","symfony","symfony-bundle","tmdb"],"created_at":"2024-12-12T22:07:24.816Z","updated_at":"2024-12-20T04:08:20.442Z","avatar_url":"https://github.com/php-tmdb.png","language":"PHP","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=SMLZ362KQ8K8W"],"categories":[],"sub_categories":[],"readme":"# A Symfony Bundle for use together with the [php-tmdb/api](https://github.com/php-tmdb/api) TMDB API Wrapper.\n\n[![License](https://poser.pugx.org/php-tmdb/symfony/license.png)](https://packagist.org/packages/php-tmdb/symfony)\n[![License](https://img.shields.io/github/v/tag/php-tmdb/symfony)](https://github.com/php-tmdb/symfony/releases)\n[![Build Status](https://img.shields.io/github/workflow/status/php-tmdb/symfony/Continuous%20Integration?label=phpunit)](https://github.com/php-tmdb/symfony/actions?query=workflow%3A%22Continuous+Integration%22)\n[![Build Status](https://img.shields.io/github/workflow/status/php-tmdb/symfony/Coding%20Standards?label=phpcs)](https://github.com/php-tmdb/symfony/actions?query=workflow%3A%22Coding+Standards%22)\n[![codecov](https://img.shields.io/codecov/c/github/php-tmdb/symfony?token=gTM9AiO5vH)](https://codecov.io/gh/php-tmdb/symfony)\n[![PHP](https://img.shields.io/badge/php-\u003e=7.3,%20\u003e=7.4,%20\u003e=8.0-8892BF.svg)](https://packagist.org/packages/php-tmdb/api)\n[![Total Downloads](https://poser.pugx.org/php-tmdb/symfony/downloads.svg)](https://packagist.org/packages/php-tmdb/symfony)\n\nCompatible with Symfony 5 and 6, PHP 7.4 and up.\n\n## Buy me a coffee, or a beer :-)\n\n\u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=SMLZ362KQ8K8W\"\u003e\u003cimg alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif\"\u003e\u003c/a\u003e\n\nMy stomach will appreciate your donation! \n\nInstallation\n------------\n\n- [Install Composer](https://getcomposer.org/doc/00-intro.md)\n- [Install php-tmdb/api dependencies](https://github.com/php-tmdb/api#installation)\n    - For development within Symfony we recommend making use of Symfony's PSR-18 HTTP Client _`Symfony\\Component\\HttpClient\\Psr18Client`_,\n      as when non-cached results pass your profiler will be filled with data.\n\nThen require the bundle:\n\n```\ncomposer require php-tmdb/symfony:^4\n```\n\nConfiguration\n----------------\nRegister the bundle in `app/bundles.php`:\n\n```php\n\u003c?php\n\nreturn [\n    // --- snip ---\n    Tmdb\\SymfonyBundle\\TmdbSymfonyBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\nAdd to your `app/config/config.yml` the following, or replace values with services of your choice ( PSR-18 Http Client / PSR-17 Factories ):\n\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    options:\n        http:\n            client: Symfony\\Component\\HttpClient\\Psr18Client\n            request_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            response_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            stream_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            uri_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n```\n\n`services.yaml`:\n\n```yaml\nservices:\n    Symfony\\Component\\HttpClient\\Psr18Client:\n        class: Symfony\\Component\\HttpClient\\Psr18Client\n\n    Nyholm\\Psr7\\Factory\\Psr17Factory:\n        class: Nyholm\\Psr7\\Factory\\Psr17Factory\n```\n\n__Configure caching__\n\nYou can use any PSR-6 cache you wish to use, we will simply use symfony's cache.\n\nWhen making use of caching, make sure to also include `php-http/cache-plugin` in composer, this plugin handles the logic for us, \nso we don't have to re-invent the wheel. \n\nYou are however also free to choose to implement your own cache listener, or add the caching logic inside the http client of your choice.\n\n```shell script\ncomposer require php-http/cache-plugin:^1.7\n```\n\nFirst off configure the cache pool in symfony `config/cache.yaml`:\n\n```yaml\nframework:\n    cache:\n        pools:\n            cache.tmdb:\n                adapter: cache.adapter.filesystem\n                default_lifetime: 86400\n```\n\nThen in your `tmdb_symfony.yaml` configuration enable the cache and reference this cache pool:\n\n```yaml\ntmdb_symfony:\n  api_key: YOUR_API_KEY_HERE\n  cache:\n    enabled: true\n    adapter: cache.tmdb\n```\n\n__Want to make use of logging?__\n\nLogging capabilities as of `4.0` allow you to make a fine-grained configuration.\n\nYou can use any PSR-3 logger you wish to use, we will simply use monolog. \n\nFirst off configure the monolog and add a channel and handler:\n\n```yaml\nmonolog:\n    channels:\n        - tmdb\n    handlers:\n        tmdb:\n            type: stream\n            path: \"%kernel.logs_dir%/php-tmdb--symfony.%kernel.environment%.log\"\n            level: info\n            channels: [\"tmdb\"]\n```\n\nThen in your `tmdb_symfony.yaml` configuration:\n\n```yaml\ntmdb_symfony:\n  api_key: YOUR_API_KEY_HERE\n  log:\n    enabled: true\n    adapter: monolog.logger.tmdb\n    hydration:\n      enabled: true\n      with_hydration_data: false # We would only recommend to enable this with an in-memory logger, so you have access to the hydration data within the profiler.\n      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.\n      listener: Tmdb\\Event\\Listener\\Logger\\LogHydrationListener\n      formatter: Tmdb\\Formatter\\Hydration\\SimpleHydrationFormatter\n    request_logging:\n      enabled: true\n      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.\n      listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n      formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n    response_logging:\n      enabled: true\n      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.\n      listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n      formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n    api_exception_logging:\n      enabled: true\n      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.\n      listener: Tmdb\\Event\\Listener\\Logger\\LogApiErrorListener\n      formatter: Tmdb\\Formatter\\TmdbApiException\\SimpleTmdbApiExceptionFormatter\n    client_exception_logging:\n      enabled: true\n      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.\n      listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n      formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n```\n\n__Disable repositories :__\n\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    repositories:\n        enabled: false\n```\n\n__Disable twig extension :__\n\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    twig_extension:\n        enabled: false\n```\n__Disable https :__\n\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    options:\n        secure:\n            enabled: false\n```\n\n__Disable legacy aliases :__\n\n_Set to true to remove all legacy alises ( e.g. `tmdb.client` or `tmdb.movie_repository` )._\n\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    disable_legacy_aliases: true\n```\n\n__Full configuration with defaults :__\n```yaml\ntmdb_symfony:\n    api_key: YOUR_API_KEY_HERE\n    cache:\n        enabled: true\n        adapter: cache.tmdb\n    log:\n        enabled: true\n        adapter: monolog.logger.tmdb\n        hydration:\n            enabled: true\n            with_hydration_data: false\n            adapter: null\n            listener: Tmdb\\Event\\Listener\\Logger\\LogHydrationListener\n            formatter: Tmdb\\Formatter\\Hydration\\SimpleHydrationFormatter\n        request_logging:\n            enabled: true\n            adapter: null\n            listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n            formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n        response_logging:\n            enabled: true\n            adapter: null\n            listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n            formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n        api_exception_logging:\n            enabled: true\n            adapter: null\n            listener: Tmdb\\Event\\Listener\\Logger\\LogApiErrorListener\n            formatter: Tmdb\\Formatter\\TmdbApiException\\SimpleTmdbApiExceptionFormatter\n        client_exception_logging:\n            enabled: true\n            adapter: null\n            listener: Tmdb\\Event\\Listener\\Logger\\LogHttpMessageListener\n            formatter: Tmdb\\Formatter\\HttpMessage\\SimpleHttpMessageFormatter\n    options:\n        bearer_token: YOUR_BEARER_TOKEN_HERE\n        http:\n            client: Symfony\\Component\\HttpClient\\Psr18Client\n            request_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            response_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            stream_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n            uri_factory: Nyholm\\Psr7\\Factory\\Psr17Factory\n        secure: true\n        host: api.themoviedb.org/3\n        guest_session_token: null\n        event_dispatcher:\n            adapter: event_dispatcher\n        hydration:\n            event_listener_handles_hydration: false\n            only_for_specified_models: {  }\n        api_token: YOUR_API_KEY_HERE # you don't have to set this if you set it at the root level\n    session_token: null\n    repositories:\n        enabled: true\n    twig_extension:\n        enabled: true\n    disable_legacy_aliases: false\n```\n\nUsage\n----------------\n\nObtaining the client\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Tmdb\\Client;\n\nclass MovieParser\n{\n    private Client $client;\n\n    // Have Symfony auto-wire the client via your constructor\n    public function __construct(Client $client)\n    {\n        $this-\u003eclient = $client;\n    }\n}\n```\n\nObtaining repositories\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Tmdb\\Model\\AbstractModel;\nuse Tmdb\\Repository\\MovieRepository;\n\nclass MovieParser\n{\n    private MovieRepository $movieRepository;\n\n    // Have Symfony auto-wire the repository via your constructor\n    public function __construct(MovieRepository $movieRepository)\n    {\n        $this-\u003emovieRepository = $movieRepository;\n    }\n\n    public function findMovie(string $id): AbstractModel\n    {\n        // Use the auto-wired repository in any of your methods\n        return $this-\u003emovieRepository-\u003eload($id);\n    }\n}\n```\n\nAn overview of all the repositories can be found in the services configuration [repositories.xml](https://github.com/php-tmdb/symfony/blob/master/Resources/config/repositories.xml).\n\nThere is also a Twig helper that makes use of the `Tmdb\\Helper\\ImageHelper` to output urls and html.\n\n```twig\n{{ movie.backdropImage|tmdb_image_url }}\n\n{{ movie.backdropImage|tmdb_image_html('original', null, 50)|raw }}\n```\n\n**For all all other interactions take a look at [php-tmdb/api](https://github.com/php-tmdb/api).**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tmdb%2Fsymfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-tmdb%2Fsymfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tmdb%2Fsymfony/lists"}