{"id":15287355,"url":"https://github.com/gregurco/guzzlebundlecacheplugin","last_synced_at":"2025-04-13T05:08:40.752Z","repository":{"id":56983442,"uuid":"108106701","full_name":"gregurco/GuzzleBundleCachePlugin","owner":"gregurco","description":"Cache Plugin for EightPointsGuzzleBundle","archived":false,"fork":false,"pushed_at":"2024-03-30T19:36:47.000Z","size":36,"stargazers_count":11,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T05:08:35.260Z","etag":null,"topics":["bundle","cache","guzzle","guzzle-bundle-plugin","guzzle-middleware","php","symfony","symfony-bundle"],"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/gregurco.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":"2017-10-24T09:40:12.000Z","updated_at":"2022-09-17T18:34:52.000Z","dependencies_parsed_at":"2024-03-30T20:40:46.275Z","dependency_job_id":null,"html_url":"https://github.com/gregurco/GuzzleBundleCachePlugin","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":"0.23809523809523814","last_synced_commit":"4e4f0fde13556ce79b03c35d960e7c227b785033"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregurco%2FGuzzleBundleCachePlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregurco%2FGuzzleBundleCachePlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregurco%2FGuzzleBundleCachePlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregurco%2FGuzzleBundleCachePlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregurco","download_url":"https://codeload.github.com/gregurco/GuzzleBundleCachePlugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"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":["bundle","cache","guzzle","guzzle-bundle-plugin","guzzle-middleware","php","symfony","symfony-bundle"],"created_at":"2024-09-30T15:27:55.565Z","updated_at":"2025-04-13T05:08:40.732Z","avatar_url":"https://github.com/gregurco.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guzzle Bundle Cache Plugin\n\n[![Build Status](https://travis-ci.org/gregurco/GuzzleBundleCachePlugin.svg?branch=master)](https://travis-ci.org/gregurco/GuzzleBundleCachePlugin)\n[![Coverage Status](https://coveralls.io/repos/gregurco/GuzzleBundleCachePlugin/badge.svg?branch=master)](https://coveralls.io/r/gregurco/GuzzleBundleCachePlugin)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/08400bb3-540d-4616-b0b3-f694a73a72cf/mini.png)](https://insight.sensiolabs.com/projects/08400bb3-540d-4616-b0b3-f694a73a72cf)\n\nThis plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients.\n\n## Requirements\n - PHP 7.2 or above\n - [Guzzle Bundle][1]\n - [Guzzle Cache middleware][2]\n\n \n## Installation\nUsing [composer][3]:\n\n##### composer.json\n``` json\n{\n    \"require\": {\n        \"gregurco/guzzle-bundle-cache-plugin\": \"dev-master\"\n    }\n}\n```\n\n##### command line\n``` bash\n$ composer require gregurco/guzzle-bundle-cache-plugin\n```\n\n## Usage\n### Enable bundle\n\n#### Symfony 2.x and 3.x\nPlugin will be activated/connected through bundle constructor in `app/AppKernel.php`, like this:\n\n``` php \nnew EightPoints\\Bundle\\GuzzleBundle\\EightPointsGuzzleBundle([\n    new Gregurco\\Bundle\\GuzzleBundleCachePlugin\\GuzzleBundleCachePlugin(),\n])\n```\n\n#### Symfony 4\nThe registration of bundles was changed in Symfony 4 and now you have to change `src/Kernel.php` to achieve the same functionality.  \nFind next lines:\n\n```php\nforeach ($contents as $class =\u003e $envs) {\n    if (isset($envs['all']) || isset($envs[$this-\u003eenvironment])) {\n        yield new $class();\n    }\n}\n```\n\nand replace them by:\n\n```php\nforeach ($contents as $class =\u003e $envs) {\n    if (isset($envs['all']) || isset($envs[$this-\u003eenvironment])) {\n        if ($class === \\EightPoints\\Bundle\\GuzzleBundle\\EightPointsGuzzleBundle::class) {\n            yield new $class([\n                new \\Gregurco\\Bundle\\GuzzleBundleCachePlugin\\GuzzleBundleCachePlugin(),\n            ]);\n        } else {\n            yield new $class();\n        }\n    }\n}\n```\n\n### Basic configuration\n``` yaml\n# app/config/config.yml\n\neight_points_guzzle:\n    clients:\n        api_payment:\n            base_url: \"http://api.domain.tld\"\n\n            # define headers, options\n\n            # plugin settings\n            plugin:\n                cache:\n                    enabled: true\n```\n\n### Configuration with specific cache strategy\n``` yaml\n# app/config/services.yml\n\nservices:\n    acme.filesystem_cache:\n        class: Doctrine\\Common\\Cache\\FilesystemCache\n        arguments: ['/tmp/']\n        public: false\n\n    acme.doctrine_cache_storage:\n        class: Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage\n        arguments: ['@acme.filesystem_cache']\n        public: false\n\n    acme.private_cache_strategy:\n        class: Kevinrob\\GuzzleCache\\Strategy\\PrivateCacheStrategy\n        arguments: ['@acme.doctrine_cache_storage']\n        public: false\n\n```\n\n``` yaml\n# app/config/config.yml\n\neight_points_guzzle:\n    clients:\n        api_payment:\n            plugin:\n                cache:\n                    enabled: true\n                    strategy: \"acme.private_cache_strategy\"\n```\n\nMore information about cache strategies can be found here: [Kevinrob/guzzle-cache-middleware][2]\n\n### Invalidate cache\n```php\n# get client\n$apiPaymentClient = $this-\u003eget('eight_points_guzzle.client.api_payment');\n\n# do a request\n$apiPaymentClient-\u003erequest('GET', 'ping');\n\n# invalidate cache\n$event = new InvalidateRequestEvent($apiPaymentClient, 'GET', 'ping');\n$this-\u003eget('event_dispatcher')-\u003edispatch(GuzzleBundleCacheEvents::INVALIDATE, $event);\n```\n\n## License\nThis middleware is licensed under the MIT License - see the LICENSE file for details\n\n[1]: https://github.com/8p/EightPointsGuzzleBundle\n[2]: https://github.com/Kevinrob/guzzle-cache-middleware\n[3]: https://getcomposer.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregurco%2Fguzzlebundlecacheplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregurco%2Fguzzlebundlecacheplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregurco%2Fguzzlebundlecacheplugin/lists"}