Welcome

This demo shows your an examples of AOP usage.

Please, choose one of available examples from navigation menu.
You can also try to run this code with XDebug.

Calling Before Interceptor for execution(Demo\Example\LoggingDemo->execute()) with arguments: ["LoggingTask"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo->perform()) with arguments: ["LoggingTask","first"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo->perform()) with arguments: ["LoggingTask","second"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo::runByName()) with arguments: ["StaticTask"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo->execute()) with arguments: ["StaticTask"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo->perform()) with arguments: ["StaticTask","first"]
Calling Before Interceptor for execution(Demo\Example\LoggingDemo->perform()) with arguments: ["StaticTask","second"]

/** * This advice intercepts an execution of loggable methods * * We use "Before" type of advice to log only class name, method name and arguments before * method execution. * You can choose your own logger, for example, monolog or log4php. * Also you can choose "After" or "Around" advice to access an return value from method. * * To inject logger into this aspect you can look at Warlock framework with DI+AOP * * @param MethodInvocation $invocation Invocation * * @Before("@execution(Demo\Annotation\Loggable)") */public function beforeMethodExecution(MethodInvocation $invocation) { echo 'Calling Before Interceptor for ',$invocation,' with arguments: ',json_encode($invocation->getArguments()),PHP_EOL; }}