{"id":16674669,"url":"https://github.com/lisachenko/yii-aspect","last_synced_at":"2025-04-09T20:22:28.131Z","repository":{"id":6805252,"uuid":"8053073","full_name":"lisachenko/yii-aspect","owner":"lisachenko","description":"Playground for integration of aspect-oriented programming with YII","archived":false,"fork":false,"pushed_at":"2013-09-28T15:12:16.000Z","size":419,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-23T22:14:03.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lisachenko.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}},"created_at":"2013-02-06T14:47:12.000Z","updated_at":"2021-08-31T09:13:59.000Z","dependencies_parsed_at":"2022-08-29T01:11:00.184Z","dependency_job_id":null,"html_url":"https://github.com/lisachenko/yii-aspect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fyii-aspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fyii-aspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fyii-aspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fyii-aspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lisachenko","download_url":"https://codeload.github.com/lisachenko/yii-aspect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248104741,"owners_count":21048397,"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":"2024-10-12T12:43:51.977Z","updated_at":"2025-04-09T20:22:28.105Z","avatar_url":"https://github.com/lisachenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Description\n------------\n\nYii skeleton with some tweaks + [Go AOP PHP](https://github.com/lisachenko/go-aop-php).\n\nThis project allows you to test [aspect-oriented programming](http://en.wikipedia.org/wiki/Aspect-oriented_programming) with Yii framework. \n\nInstallation\n------------\n\nInstallation process is pretty easy, only few steps:\n```bash\ngit clone https://github.com/lisachenko/yii-aspect.git \u0026\u0026 cd yii-aspect\ncomposer install\n```\n\nAfter that add a `/app` folder as a home directory for web server and just open it in browser.\n\nAspect definition\n-----------------\n\nAspect class is defined in [TestMonitorAspect](https://github.com/lisachenko/yii-aspect/blob/master/app/protected/extensions/go-aop-php/TestMonitorAspect.php) class:\n\n```php\n\u003c?php\nnamespace Aspect;\n\nuse Go\\Aop\\Aspect;\nuse Go\\Aop\\Intercept\\FieldAccess;\nuse Go\\Aop\\Intercept\\MethodInvocation;\nuse Go\\Lang\\Annotation\\After;\nuse Go\\Lang\\Annotation\\Before;\nuse Go\\Lang\\Annotation\\Around;\nuse Go\\Lang\\Annotation\\Pointcut;\n\n/**\n * Monitor aspect\n */\nclass TestMonitorAspect implements Aspect\n{\n\n    /**\n     * Method that will be called before real method\n     *\n     * @param MethodInvocation $invocation Invocation\n     * @Before(\"within(**)\")\n     */\n    public function beforeMethodExecution(MethodInvocation $invocation)\n    {\n        $obj = $invocation-\u003egetThis();\n        echo 'Calling Before Interceptor for method: ',\n             is_object($obj) ? get_class($obj) : $obj,\n             $invocation-\u003egetMethod()-\u003eisStatic() ? '::' : '-\u003e',\n             $invocation-\u003egetMethod()-\u003egetName(),\n             '()',\n             ' with arguments: ',\n             json_encode($invocation-\u003egetArguments()),\n             \"\u003cbr\u003e\\n\";\n    }\n}\n```\n\nHow it works? \n-------------\n\nMain feature of AOP is that it doesn't require any changes in the original source code. There is a weaver that modifies logic of original classes and methods according to the rules defined in aspects. So in our example we create an advice (body of the beforeMethodExecution() method) that will receive a MethodInvocation instance as an argument. Next step is to decide where this advice should be applied (it's a pointcut). Here we define \"within\" pointcut for all public and protected methods (both dynamic and static) with the help of \"**\" that will match any class. Annotation \"@Before\" is used to specify, that we want our hook to be called before original method.\n\nEach aspect should be registed in the application [aspect kernel](https://github.com/lisachenko/yii-aspect/blob/master/app/protected/extensions/go-aop-php/ApplicationAspectKernel.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisachenko%2Fyii-aspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flisachenko%2Fyii-aspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisachenko%2Fyii-aspect/lists"}