{"id":26360998,"url":"https://github.com/we7coreteam/w7-rangine-aspect","last_synced_at":"2026-01-03T21:03:58.710Z","repository":{"id":62545976,"uuid":"387651350","full_name":"we7coreteam/w7-rangine-aspect","owner":"we7coreteam","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-17T11:07:11.000Z","size":70,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-10T03:26:19.159Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/we7coreteam.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":"2021-07-20T02:40:55.000Z","updated_at":"2022-06-16T11:19:19.000Z","dependencies_parsed_at":"2022-11-02T22:15:36.815Z","dependency_job_id":null,"html_url":"https://github.com/we7coreteam/w7-rangine-aspect","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/we7coreteam%2Fw7-rangine-aspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/we7coreteam%2Fw7-rangine-aspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/we7coreteam%2Fw7-rangine-aspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/we7coreteam%2Fw7-rangine-aspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/we7coreteam","download_url":"https://codeload.github.com/we7coreteam/w7-rangine-aspect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902382,"owners_count":20366271,"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","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-03-16T17:19:11.543Z","updated_at":"2026-01-03T21:03:58.654Z","avatar_url":"https://github.com/we7coreteam.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 安装\n\n```\ncomposer require w7/rangine-aspect\n```\n\n## 在rangine中使用\n\n直接安装即可\n\n## 在laravel中使用\n\n直接安装即可。\n\n\n\n### 编写Aspect\n\n首先让我们编写待切入类\n\n```php\n\u003c?php\n\nnamespace W7\\App\\Services;\n\nclass TestAspectService {\n\tpublic function test($arg) {\n\t\treturn $arg;\n\t}\n\n\tpublic function test1() {\n\t\treturn 1;\n\t}\n\n\tpublic function test2() {\n\t\treturn 2;\n\t}\n}\n```\n\n其次新增对应的 `TestAspect`\n\n```php\n\u003c?php\n\nnamespace W7\\App\\Aspect;\n\nuse W7\\App\\Services\\TestAspectService;\nuse W7\\Aspect\\Aop\\AspectAbstract;\nuse W7\\Aspect\\Aop\\AspectJoinPoint;\n\nclass TestAspect extends AspectAbstract {\n    //表示切入到TestAspectService类的test和test1方法\n\tpublic static $classMethodMap = [\n\t\tTestAspectService::class =\u003e [\n\t\t\t'test',\n\t\t\t'test1'\n\t\t]\n\t];\n\n\tpublic function process(AspectJoinPoint $aspectJoinPoint, \\Closure $next) {\n\t\tvar_dump('aspect before ' . $aspectJoinPoint-\u003eclass . ':' . $aspectJoinPoint-\u003emethod);\n\n\t\t$result = $next($aspectJoinPoint);\n\n\t\tvar_dump('aspect after ' . $aspectJoinPoint-\u003eclass . ':' . $aspectJoinPoint-\u003emethod);\n\n\t\treturn $result;\n\t}\n}\n```\n\n### 生成代理类配置\nrangine\n```\nbin/gerent aspect:build\n```\nlaravel\n```\nphp artisan aspect:build\n```\n\n使用\n```php\n(new TestAspectService())-\u003etest('woshishui');\nvar_dump((new TestAspectService())-\u003etest1());\nvar_dump((new TestAspectService())-\u003etest2());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwe7coreteam%2Fw7-rangine-aspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwe7coreteam%2Fw7-rangine-aspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwe7coreteam%2Fw7-rangine-aspect/lists"}