{"id":18520120,"url":"https://github.com/php-di/zf2-bridge","last_synced_at":"2026-03-09T23:01:35.131Z","repository":{"id":9711388,"uuid":"11664899","full_name":"PHP-DI/ZF2-Bridge","owner":"PHP-DI","description":"PHP-DI integration with Zend Framework 2","archived":false,"fork":false,"pushed_at":"2018-11-21T11:32:08.000Z","size":152,"stargazers_count":11,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-21T16:46:14.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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-DI.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}},"created_at":"2013-07-25T16:05:28.000Z","updated_at":"2018-11-21T11:32:10.000Z","dependencies_parsed_at":"2022-07-08T03:40:51.818Z","dependency_job_id":null,"html_url":"https://github.com/PHP-DI/ZF2-Bridge","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/PHP-DI/ZF2-Bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2FZF2-Bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2FZF2-Bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2FZF2-Bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2FZF2-Bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHP-DI","download_url":"https://codeload.github.com/PHP-DI/ZF2-Bridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2FZF2-Bridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281180159,"owners_count":26456889,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-06T17:18:40.447Z","updated_at":"2025-10-26T22:11:56.898Z","avatar_url":"https://github.com/PHP-DI.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-DI integration with Zend Framework 2\n\n[![Build Status](https://travis-ci.org/PHP-DI/ZF2-Bridge.svg)](https://travis-ci.org/PHP-DI/ZF2-Bridge)\n\nThis library provides integration for PHP-DI with Zend Framework 2.\n\n[PHP-DI](http://php-di.org/) is a Dependency Injection Container for PHP.\n\nIf you are looking for Zend Framework 1 integration, head over [here](https://github.com/php-di/PHP-DI-ZF1).\n\n## Use\n\nRequire the libraries with Composer:\n\n```json\n{\n    \"require\": {\n        \"php-di/php-di\": \"*\",\n        \"php-di/zf2-bridge\": \"*\"\n    }\n}\n```\n\nTo use PHP-DI in your ZF2 application, you need to edit `application_root/config/application.config.php`:\n\n```php\n    // ...\n    'modules' =\u003e [\n        ...\n        'DI\\ZendFramework2',\n        ...\n    ],\n\n    'service_manager' =\u003e [\n        // ...\n        'factories' =\u003e [\n            'DI\\Container' =\u003e 'DI\\ZendFramework2\\Service\\DIContainerFactory',\n        ],\n    ],\n```\n\nThat's it!\n\nNow you dependencies are injected in your controllers!\n\nIf you'd like to specify the di configuration yourself, create this file: `application_root/config/php-di.config.php`\nand save it with your PHP DI configuration e.g. like this:\n\n```\nreturn [\n    'Application\\Service\\GreetingServiceInterface' =\u003e Di\\object('Application\\Service\\GreetingService'),\n];\n```\n\nHead over to [PHP-DI's documentation](http://php-di.org/doc/) if needed.\n\n## Fine tuning\n\nTo configure the module, you have to override the module config somewhere at config/autoload/global.php\nor config/autoload/local.php.\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        ...\n    ]\n];\n```\n\n### Override definitions file location\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'definitionsFile' =\u003e realpath(__DIR__ . '/../my.custom.def.config.php'),\n    ]\n];\n```\n\n### Enable or disable annotations\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'useAnntotations' =\u003e true,\n    ]\n];\n```\n\n### Enable APCu\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'cache' =\u003e [\n            'adapter' =\u003e 'apcu',\n            'namespace' =\u003e 'your_di_cache_key',\n        ],\n    ]\n];\n```\n\n### Enable file cache\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'cache' =\u003e [\n            'adapter' =\u003e 'filesystem',\n            'namespace' =\u003e 'your_di_cache_key',\n            'directory' =\u003e 'your_cache_directory', // default value is data/php-di/cache\n        ],\n    ]\n];\n```\n\n### Enable redis cache\n\nIf you are also using Redis for storing php sessions, it is very useful to configure the php-di\ncache handler to use a different database, since you might accidentally delete all your sessions\nwhen clearing the php-di definitions cache.\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'cache' =\u003e [\n            'namespace' =\u003e 'your_di_cache_key',\n            'adapter' =\u003e 'redis',\n            'host' =\u003e 'localhost', // default is localhost\n            'port' =\u003e 6379, // default is 6379\n            'database' =\u003e 1, // default is the same as phpredis default\n        ],\n    ]\n];\n```\n\n### Enable Memcached cache\n\nIf you're using Memcached, you should have only one project per memcached instance.\n\n```php\nreturn [\n    'phpdi-zf2' =\u003e [\n        'cache' =\u003e [\n            'adapter' =\u003e 'memcached',\n            'host' =\u003e 'localhost', // default is localhost\n            'port' =\u003e 11211, // default is 11211\n        ],\n    ]\n];\n```\n\n## Console commands\n\n### Clear definition cache\n\nTo clear the definition cache, run the following command from the project root:\n\n```\nphp public/index.php php-di-clear-cache\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-di%2Fzf2-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-di%2Fzf2-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-di%2Fzf2-bridge/lists"}