{"id":31908328,"url":"https://github.com/enzyme/laravel-binder","last_synced_at":"2025-10-13T15:27:03.513Z","repository":{"id":56978268,"uuid":"49933292","full_name":"enzyme/laravel-binder","owner":"enzyme","description":"A service container contextual binding helper for Laravel 5.","archived":false,"fork":false,"pushed_at":"2016-09-22T06:08:54.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-11T09:47:15.952Z","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/enzyme.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":"2016-01-19T07:01:15.000Z","updated_at":"2016-07-08T20:40:39.000Z","dependencies_parsed_at":"2022-08-21T11:50:30.746Z","dependency_job_id":null,"html_url":"https://github.com/enzyme/laravel-binder","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/enzyme/laravel-binder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Flaravel-binder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Flaravel-binder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Flaravel-binder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Flaravel-binder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enzyme","download_url":"https://codeload.github.com/enzyme/laravel-binder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Flaravel-binder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015922,"owners_count":26085778,"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-13T02:00:06.723Z","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":"2025-10-13T15:26:54.659Z","updated_at":"2025-10-13T15:27:03.491Z","avatar_url":"https://github.com/enzyme.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binder\n\n[![Build Status](https://travis-ci.org/enzyme/laravel-binder.svg?branch=master)](https://travis-ci.org/enzyme/laravel-binder)\n[![Coverage Status](https://coveralls.io/repos/github/enzyme/laravel-binder/badge.svg?branch=master)](https://coveralls.io/github/enzyme/laravel-binder?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/enzyme/laravel-binder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/enzyme/laravel-binder/?branch=master)\n\nA contextual binding helper for Laravel 5.\n\n# Example\n\n#### From the service provider.\n\n```php\nuse Enzyme\\LaravelBinder\\Binder;\n\n// Inside the app service provider...\npublic function register()\n{\n    $binder = new Binder($this-\u003eapp);\n\n    $binder-\u003esetAlias(\n        'controller.listing',\n        'App\\Http\\Controllers\\ListingController'\n    );\n\n    $binder-\u003esetAlias(\n        'repos.interface',\n        'Acme\\Repositories\\RepositoryInterface'\n    );\n\n    // Option 1 for binding, using aliases.\n    $binder-\u003esetBinding(\n        'repos.listing',\n        'repos.interface',\n        'Acme\\Repositories\\ListingRepository'\n    );\n\n    // Option 2 for binding, using FQNs.\n    $binder-\u003esetBinding(\n        'factories.listing',\n        'Acme\\Factories\\FactoryInterface',\n        'Acme\\Factories\\ListingFactory'\n    );\n\n    // Tell the service container that the ListingController\n    // needs the ListingRepository \u0026 ListingFactory.\n    $binder-\u003esetNeeds(\n        'controller.listing',\n        ['repos.listing', 'factories.listing']\n    );\n\n    $binder-\u003eregister();\n}\n```\n\n#### From the controller\n\n```php\n// You don't need to inject the specific concrete classes, just the\n// interfaces. The Binder + Service Container has taken care of it for you.\npublic function __construct(RepositoryInterface $repo, FactoryInterface $factory)\n{\n    $this-\u003erepo = $repo;\n    $this-\u003efactory = $factory;\n}\n```\n\n# What's the purpose?\n\nWith your service provider(s) now being the sole authority for which classes get what implementations, if you ever need to switch those implementations, it's dead simple and in one spot!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzyme%2Flaravel-binder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenzyme%2Flaravel-binder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzyme%2Flaravel-binder/lists"}