{"id":42204501,"url":"https://github.com/friendsofthinkphp/think-template-magic","last_synced_at":"2026-01-27T00:31:28.771Z","repository":{"id":57084000,"uuid":"223326899","full_name":"friendsofthinkphp/think-template-magic","owner":"friendsofthinkphp","description":"ThinkPHP6 模板上加点魔法","archived":false,"fork":false,"pushed_at":"2019-12-07T04:23:52.000Z","size":9,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T22:35:17.638Z","etag":null,"topics":["thinkphp","thinkphp-component"],"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/friendsofthinkphp.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":"2019-11-22T05:00:52.000Z","updated_at":"2023-09-28T05:23:36.000Z","dependencies_parsed_at":"2022-08-24T14:10:11.438Z","dependency_job_id":null,"html_url":"https://github.com/friendsofthinkphp/think-template-magic","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/friendsofthinkphp/think-template-magic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendsofthinkphp%2Fthink-template-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendsofthinkphp%2Fthink-template-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendsofthinkphp%2Fthink-template-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendsofthinkphp%2Fthink-template-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendsofthinkphp","download_url":"https://codeload.github.com/friendsofthinkphp/think-template-magic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendsofthinkphp%2Fthink-template-magic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28793339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:49:50.245Z","status":"ssl_error","status_checked_at":"2026-01-26T21:48:29.455Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["thinkphp","thinkphp-component"],"created_at":"2026-01-27T00:31:28.611Z","updated_at":"2026-01-27T00:31:28.767Z","avatar_url":"https://github.com/friendsofthinkphp.png","language":"PHP","readme":"# think-template-magic\n帮助你在模板上加点魔法\n\n如果你项目模板很多，难于维护，可以使用此工具添加（例如全局样式，javascript，广告等等）。\n\n只适用 ThinkPHP `6.0`\n\n## 安装\n```sh\n$ composer require xiaodi/think-templte-magic\n```\n\n## 使用\n例子 添加一个`css`样式\n```php\n\u003c?php\n\nnamespace app;\n\nuse xiaodi\\Contracts\\TemplateMagicHandleInterface;\nuse xiaodi\\Contracts\\TemplateMagicReplaceInterface;\n\nclass Replace implements TemplateMagicHandleInterface\n{\n    public function handle(TemplateMagicReplaceInterface $handle)\n    {\n        $handle-\u003ehead('\u003clink rel=\"stylesheet\" href=\"https://static.kodcloud.com/index/js/lib/bootstrap-3.3.7/css/bootstrap.min.css\"\u003e');\n    }\n}\n\n```\n\n### 配置\n`config/template_magic.php`\n\n```php\nuse app\\Replace;\n\nreturn [\n    'handle' =\u003e Replace::class\n]\n```\n\n支持闭包\n```php\nuse xiaodi\\Contracts\\TemplateMagicReplaceInterface;\n\nreturn [\n    'handle' =\u003e function (TemplateMagicReplaceInterface $handle) {\n        $handle-\u003ehead('\u003clink rel=\"stylesheet\" href=\"https://static.kodcloud.com/index/js/lib/bootstrap-3.3.7/css/bootstrap.min.css\"\u003e');\n    }\n];\n\n```\n\n### func\n* `$handle-\u003ehead($content)` 插入内容到`\u003c/head\u003e`标签前\n* `$handle-\u003ebody($content)` 插入内容到`\u003c/body\u003e`标签前\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendsofthinkphp%2Fthink-template-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendsofthinkphp%2Fthink-template-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendsofthinkphp%2Fthink-template-magic/lists"}