{"id":34014132,"url":"https://github.com/coolephp/goaop","last_synced_at":"2025-12-13T13:53:52.929Z","repository":{"id":56957778,"uuid":"327778425","full_name":"coolephp/goaop","owner":"coolephp","description":"Provide AOP aspect oriented programming capability. - 提供 AOP 面向切面编程能力。","archived":false,"fork":false,"pushed_at":"2021-01-08T07:48:38.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-23T04:43:56.343Z","etag":null,"topics":["aop","aspect","coole","goaop","php"],"latest_commit_sha":null,"homepage":"https://www.guanguans.cn/coole/#/zh-cn/goaop","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/coolephp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null},"funding":{"patreon":"guanguans","custom":"https://www.guanguans.cn/images/wechat.jpeg"}},"created_at":"2021-01-08T02:31:24.000Z","updated_at":"2021-06-25T06:17:58.000Z","dependencies_parsed_at":"2022-08-21T09:50:18.847Z","dependency_job_id":null,"html_url":"https://github.com/coolephp/goaop","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coolephp/goaop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolephp%2Fgoaop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolephp%2Fgoaop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolephp%2Fgoaop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolephp%2Fgoaop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coolephp","download_url":"https://codeload.github.com/coolephp/goaop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolephp%2Fgoaop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27706671,"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-12-13T02:00:09.769Z","response_time":147,"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":["aop","aspect","coole","goaop","php"],"created_at":"2025-12-13T13:53:51.264Z","updated_at":"2025-12-13T13:53:52.921Z","avatar_url":"https://github.com/coolephp.png","language":"PHP","readme":"# coole/goaop\n\n\u003e Bringing the goaop to Coole. - 将 goaop 集成到 Coole。\n\n[![Tests](https://github.com/coolephp/goaop/workflows/Tests/badge.svg)](https://github.com/coolephp/goaop/actions)\n[![Check \u0026 fix styling](https://github.com/coolephp/goaop/workflows/Check%20\u0026%20fix%20styling/badge.svg)](https://github.com/coolephp/goaop/actions)\n[![codecov](https://codecov.io/gh/coolephp/goaop/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/coolephp/goaop)\n[![Latest Stable Version](https://poser.pugx.org/coolephp/goaop/v)](//packagist.org/packages/coolephp/goaop)\n[![Total Downloads](https://poser.pugx.org/coolephp/goaop/downloads)](//packagist.org/packages/coolephp/goaop)\n[![License](https://poser.pugx.org/coolephp/goaop/license)](//packagist.org/packages/coolephp/goaop)\n\n## Requirement\n\n* Coole \u003e= 1.0\n\n## Installation\n\n``` bash\n$ composer require coolephp/goaop -vvv\n```\n\n## Usage\n\n### Configuration\n\n1. Copy `goaop/config/goaop.php` to `coole-skeleton/config/goaop.php`.\n2. Config `\\Coole\\Goaop\\GoAopServiceProvider::class` service provider.\n\n``` php\n\u003c?php\n\nreturn [\n    /*\n     * App 名称\n     */\n    'name' =\u003e env('APP_NAME', 'Coole'),\n    \n    ...\n\n    /*\n     * 第三方服务\n     */\n    'providers' =\u003e [\n        \\Coole\\Goaop\\GoAopServiceProvider::class\n    ],\n    \n    ...\n];\n\n```\n\n3. Add a aspect configuration for `config/goaop.php`.\n\n``` php\n\u003c?php\n\nreturn [\n    /*\n     * AOP Debug Mode\n     */\n    'debug' =\u003e env('GOAOP_DEBUG', env('APP_DEBUG', false)),\n    \n    ...\n    \n    /*\n     * Yours aspects\n     */\n    'aspects' =\u003e [\n        \\App\\Aspect\\LoggingServiceAspect::class,\n    ],\n];\n```\n\n### Create a class `app\\Service\\LoggingService`\n\n``` php\n\u003c?php\n\nnamespace App\\Service;\n\nclass LoggingService\n{\n    public static function logging()\n    {\n        return true;\n    }\n}\n```\n\n### Create a aspect `App\\Aspect\\LoggingServiceAspect`\n\n``` php\n\u003c?php\n\nnamespace App\\Aspect;\n\nuse Go\\Aop\\Aspect;\nuse Go\\Aop\\Intercept\\MethodInvocation;\nuse Go\\Lang\\Annotation\\After;\nuse Go\\Lang\\Annotation\\Before;\n\nclass LoggingServiceAspect implements Aspect\n{\n    /**\n     * Method that will be called before real method.\n     *\n     * @param MethodInvocation $invocation Invocation\n     * @Before(\"execution(public App\\Service\\LoggingService::logging(*))\")\n     */\n    public function beforeMethodExecution(MethodInvocation $invocation)\n    {\n        file_put_contents(base_path('runtime/logging.log'), 'this is a before method testing.'.PHP_EOL, FILE_APPEND);\n    }\n\n    /**\n     * Method that will be called after real method.\n     *\n     * @param MethodInvocation $invocation Invocation\n     * @After(\"execution(public App\\Service\\LoggingService::logging(*))\")\n     */\n    public function afterMethodExecution(MethodInvocation $invocation)\n    {\n        file_put_contents(base_path('runtime/logging.log'), 'this is a after method testing.'.PHP_EOL, FILE_APPEND);\n    }\n}\n```\n\n### Run `App\\Service\\LoggingService::logging()`\n\ncat `runtime/logging.log`\n\n``` bash\n───────┬───────────────────────────────────────────────────────────────────\n       │ File: runtime/logging.log\n───────┼───────────────────────────────────────────────────────────────────\n   1   │ this is a before method testing.\n   2   │ this is a after method testing.\n───────┴───────────────────────────────────────────────────────────────────\n```\n\n###\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n* [guanguans](https://github.com/guanguans)\n* [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":["https://patreon.com/guanguans","https://www.guanguans.cn/images/wechat.jpeg"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolephp%2Fgoaop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoolephp%2Fgoaop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolephp%2Fgoaop/lists"}