{"id":33984112,"url":"https://github.com/zorac/php-di-migration","last_synced_at":"2026-05-28T01:05:06.936Z","repository":{"id":153719375,"uuid":"629918066","full_name":"zorac/php-di-migration","owner":"zorac","description":"Eases migration from PHP-DI 6 annotations to PHP-DI 7 attributes","archived":false,"fork":false,"pushed_at":"2023-04-20T10:36:24.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T16:46:22.464Z","etag":null,"topics":["php","php-di"],"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/zorac.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-19T09:37:23.000Z","updated_at":"2023-07-03T17:43:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0a2c8e2-b66a-4759-85fe-9897fa0c7464","html_url":"https://github.com/zorac/php-di-migration","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zorac/php-di-migration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorac%2Fphp-di-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorac%2Fphp-di-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorac%2Fphp-di-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorac%2Fphp-di-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zorac","download_url":"https://codeload.github.com/zorac/php-di-migration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorac%2Fphp-di-migration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33589685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"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":["php","php-di"],"created_at":"2025-12-13T04:21:20.061Z","updated_at":"2026-05-28T01:05:06.931Z","avatar_url":"https://github.com/zorac.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-DI Migration\n\n[![Software license][ico-license]](LICENSE)\n[![PHP version][ico-php]][link-php]\n[![Latest release][ico-packagist]][link-packagist]\n\nEases migration from PHP-DI 6 annotations to PHP-DI 7 attributes.\n\n## Rationale\n\nPHP-DI 7 replaces the usage of PHPDoc `@Inject` and `@Injectable` annotations\nwith native PHP 8 `#[Inject]` and `#[Injectable]` attributes. This is very much\na change for the better, but all of your code needs to be updated at once,\nwhich can be difficult or dangerous across a large codebase with multiple\ncontributors. This project provides a smoother migration path by supporting\nattributes alongside annotations while you migrate your code.\n\n## Warning\n\nThis code has not been extensively tested for all use cases and edge cases.\nUse at your own risk!\n\n## Usage\n\nInstall the migration package alongside PHP-DI 6:\n```sh\ncomposer require zorac/php-di-migration\n```\nReplace `ContainerBuilder` with `MigrationContainerBuilder` and enable\nannotations:\n```php\n// Before:\n$builder = new DI\\ContainerBuilder();\n$builder-\u003euseAnnotations(true);\n// etc...\n$container = $builder-\u003ebuild();\n\n// After:\n$builder = new DI\\MigrationContainerBuilder();\n$builder-\u003euseAnnotations(true);\n$builder-\u003euseAttributes(true);\n// etc...\n$container = $builder-\u003ebuild();\n```\nCommit and merge the changes, and you're ready to start migrating!\n\nOver time, migrate your code from attributes to annotations, remembering to add\nstrong PHP types anywhere you're currently relying on PHPDoc typing, and to\nremove any imports of `DI\\Annotation\\Inject` etc.\n\nOnce your code is all migrated, remove the `useAnnotations(false)` call from\nthe container builder for final testing. If you missed any typing changes, this\nis when things will break.\n\nOnce you're happy with your fully migrated code, you can remove\n`zorac/php-di-migration` and upgrade to PHP-DI 7, switching back to using\n`DI\\ContainerBuilder`. You may also be able to remove `doctrine/annotations` if\nyou're not relying on it for anything else.\n\nCongratulations! Your PHP-DI migration is complete.\n\n## Implementation Notes\n\n* `MigrationContainerBuilder` is a modified version of PHP-DI 6's\n  `ContainerBuilder` with changes ported from PHP-DI 7's version to add support\n  for `useAttributes`, and additional changes to support annotations and\n  attributes in parallel.\n* `AttributeAndAnnotationBasedAutowiring` is a modified version of PHP-DI 6's\n  `AnnotationBasedAutowiring` with changes ported from PHP-DI 7's\n  `AttributeBasedAutowiring` to support annotations and attributes in parallel.\n* All other classes are copied verbatim from PHP-DI 7.\n\n[ico-license]: https://img.shields.io/github/license/zorac/php-di-migration.svg?style=flat-square\n[ico-php]: https://img.shields.io/packagist/php-v/zorac/php-di-migration.svg?style=flat-square\n[ico-packagist]: https://img.shields.io/packagist/v/zorac/php-di-migration.svg?style=flat-square\n[link-php]: https://www.php.net/\n[link-packagist]: https://packagist.org/packages/zorac/php-di-migration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzorac%2Fphp-di-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzorac%2Fphp-di-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzorac%2Fphp-di-migration/lists"}