PHPackages                             adgoal/goaop-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. adgoal/goaop-framework

ActiveLibrary

adgoal/goaop-framework
======================

Framework for aspect-oriented programming in PHP.

2.2.1(7y ago)02161MITPHPPHP &gt;=7.2.0

Since Jan 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Adgoal/goaop-framework)[ Packagist](https://packagist.org/packages/adgoal/goaop-framework)[ Docs](http://go.aopphp.com/)[ RSS](/packages/adgoal-goaop-framework/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (11)Versions (33)Used By (1)

Go! Aspect-Oriented Framework for PHP
-------------------------------------

[](#go-aspect-oriented-framework-for-php)

Go! AOP is a modern aspect-oriented framework in plain PHP with rich features for the new level of software development. The framework allows cross-cutting issues to be solved in the traditional object-oriented PHP code by providing a highly efficient and transparent hook system for your exisiting code.

[![Build Status](https://camo.githubusercontent.com/d7879afe80ca3474cfd1bc379f61d74e564508c08e6e33916af55a511c0571a9/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f676f616f702f6672616d65776f726b2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/goaop/framework)[![GitHub release](https://camo.githubusercontent.com/f646581a91ee9a6d44b7bcb6f0bcea7b2fada2e0c72ad966d1a8308321499daa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f676f616f702f6672616d65776f726b2e737667)](https://github.com/goaop/framework/releases/latest)[![Total Downloads](https://camo.githubusercontent.com/c12cdf1ed5de9d3579a8d088d6336eab98d44811c87d606343e6470713b29346/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f616f702f6672616d65776f726b2e737667)](https://packagist.org/packages/goaop/framework)[![Daily Downloads](https://camo.githubusercontent.com/7e9e094a37fe6dd3cb91c20f0099415dc19f175de55d354c5519e6fb4798b660/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f676f616f702f6672616d65776f726b2e737667)](https://packagist.org/packages/goaop/framework)[![SensioLabs Insight](https://camo.githubusercontent.com/cabbb58f046fceec5fb194fb471f50f6db027fabbe067b36abfa3577fee45efc/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f39663365366465312d656131342d343931302d623264652d3939666634333163393235322e737667)](https://insight.sensiolabs.com/projects/9f3e6de1-ea14-4910-b2de-99ff431c9252)[![Minimum PHP Version](https://camo.githubusercontent.com/e97290c4047b8fc1152177fc8110cab416f31f18159b722b6b633a210a198861/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/92aa701707799aee9ecf06d197f7acb9a230f22609dba3aec7e9d59602ce7c03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f676f616f702f6672616d65776f726b2e737667)](https://packagist.org/packages/goaop/framework)

Features
--------

[](#features)

- Provides dynamic hook system for PHP without changes in the original source code.
- Doesn't require any PECL-extentions (php-aop, runkit, uopz) and DI-containers to work.
- Object-oriented design of aspects, joinpoints and pointcuts.
- Intercepting an execution of any public or protected method in a classes.
- Intercepting an execution of static methods and methods in final classes.
- Intercepting an execution of methods in the traits.
- Intercepting an access to the public/protected properties for objects.
- Hooks for static class initialization (after class is loaded into PHP memory).
- Hooks for object initialization (intercepting `new` keywords).
- Intercepting an invocation of system PHP functions.
- Ability to change the return value of any methods/functions via `Around` type of advice.
- Rich pointcut grammar syntax for defining pointcuts in the source code.
- Native debugging for AOP with XDebug. The code with weaved aspects is fully readable and native. You can put a breakpoint in the original class or in the aspect and it will work (for debug mode)!
- Can be integrated with any existing PHP frameworks and libraries (with or without additional configuration).
- Highly optimized for production use: support of opcode cachers, lazy loading of advices and aspects, joinpoints caching, no runtime checks of pointcuts, no runtime annotations parsing, no evals and `__call` methods, no slow proxies and `call_user_func_array()`. Fast bootstraping process (2-20ms) and advice invocation.

What is AOP?
------------

[](#what-is-aop)

[AOP (Aspect-Oriented Programming)](http://en.wikipedia.org/wiki/Aspect-oriented_programming) is an approach to cross-cutting concerns, where these concerns are designed and implemented in a "modular" way (that is, with appropriate encapsulation, lack of duplication, etc.), then integrated into all the relevant execution points in a succinct and robust way, e.g. through declarative or programmatic means.

In AOP terms, the execution points are called join points. A set of those points is called a pointcut and the new behavior that is executed before, after, or "around" a join point is called advice. You can read more about AOP in [Introduction](http://go.aopphp.com/docs/introduction/) section.

Installation
------------

[](#installation)

Go! AOP framework can be installed with composer. Installation is quite easy:

1. Download the framework using composer
2. Create an application aspect kernel
3. Configure the aspect kernel in the front controller
4. Create an aspect
5. Register the aspect in the aspect kernel

### Step 0 (optional): Try demo examples in the framework

[](#step-0-optional-try-demo-examples-in-the-framework)

Ask composer to create new project in empty directory:

```
composer create-project goaop/framework
```

After that just configure your web server to `demos/` folder and open it in your browser. Then you can look at some demo examples before going deeper into installing it in your project.

### Step 1: Download the library using composer

[](#step-1-download-the-library-using-composer)

Ask composer to download the latest version of Go! AOP framework with its dependencies by running the command:

```
composer require goaop/framework
```

Composer will install the framework to your project's `vendor/goaop/framework` directory.

### Step 2: Create an application aspect kernel

[](#step-2-create-an-application-aspect-kernel)

The aim of this framework is to provide easy AOP integration for your application. You have to first create the `AspectKernel` class for your application. This class will manage all aspects of your application in one place.

The framework provides base class to make it easier to create your own kernel. To create your application kernel, extend the abstract class `Go\Core\AspectKernel`

```
