{"id":19001733,"url":"https://github.com/ledccn/ledc-container","last_synced_at":"2026-06-19T12:32:33.133Z","repository":{"id":228977866,"uuid":"775459242","full_name":"ledccn/ledc-container","owner":"ledccn","description":"容器管理类、驱动管理类、Facade管理类","archived":false,"fork":false,"pushed_at":"2025-08-07T00:25:55.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-28T06:15:14.317Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ledccn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-03-21T12:35:59.000Z","updated_at":"2025-08-07T00:25:28.000Z","dependencies_parsed_at":"2025-07-26T18:21:54.113Z","dependency_job_id":null,"html_url":"https://github.com/ledccn/ledc-container","commit_stats":null,"previous_names":["ledccn/ledc-container"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ledccn/ledc-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fledc-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fledc-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fledc-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fledc-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ledccn","download_url":"https://codeload.github.com/ledccn/ledc-container/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fledc-container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34532253,"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-06-19T02:00:06.005Z","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-08T18:12:30.576Z","updated_at":"2026-06-19T12:32:33.113Z","avatar_url":"https://github.com/ledccn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP Container \u0026 Facade Manager( Support PSR-11)\n===============\n\n## 安装\n~~~\ncomposer require ledc/container\n~~~\n\n## 特性\n\n* 支持PSR-11规范\n* 支持依赖注入\n* 支持Facade门面\n* 支持容器对象绑定\n* 支持闭包绑定\n* 支持接口绑定\n\n## Container\n~~~\n// 获取容器实例\n$container = \\Ledc\\Container\\App::getInstance();\n// 绑定一个类、闭包、实例、接口实现到容器\n$container-\u003ebind('cache', '\\app\\common\\Cache');\n// 判断是否存在对象实例\n$container-\u003ehas('cache');\n// 从容器中获取对象的唯一实例\n$container-\u003eget('cache');\n// 从容器中获取对象，没有则自动实例化\n$container-\u003emake('cache');\n// 删除容器中的对象实例\n$container-\u003edelete('cache');\n// 执行某个方法或者闭包 支持依赖注入\n$container-\u003einvoke($callable, $vars);\n// 执行某个类的实例化 支持依赖注入\n$container-\u003einvokeClass($class, $vars);\n// 静态方法获取容器对象实例 不存在则自动实例化\n\\Ledc\\Container\\App::pull('cache');\n~~~\n\n对象化操作\n~~~\n// 获取容器实例\n$container = \\Ledc\\Container\\App::getInstance();\n// 绑定一个类、闭包、实例、接口实现到容器\n$container-\u003ecache = '\\app\\common\\Cache';\n// 判断是否存在对象实例\nisset($container-\u003ecache);\n// 从容器中获取对象的唯一实例\n$container-\u003ecache;\n// 删除容器中的对象实例\nunset($container-\u003ecache);\n~~~\n\n## Facade\n\n\n定义一个`app\\facade\\App`类之后，即可以静态方式调用`\\think\\App`类的动态方法\n~~~\n\u003c?php\nnamespace think;\nclass App \n{\n\tpublic function name(){\n\t\treturn 'app';\n\t}\n}\n~~~\n\n~~~\n\u003c?php\nnamespace app\\facade;\n\nuse Ledc\\Container\\Facade;\n\nclass App extends Facade\n{\n    /**\n     * 获取当前Facade对应类名\n     * @access protected\n     * @return string\n     */\n    protected static function getFacadeClass()\n    {\n\treturn '\\think\\App';\n    }\n}\n~~~\n\n然后就可以静态方式调用动态方法了\n~~~\nuse app\\facade\\App;\n\necho App::name(); // app\n~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fledc-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fledccn%2Fledc-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fledc-container/lists"}