1. Go to this page and download the library: Download pugx/aop library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pugx / aop example snippets
php
namespace Example;
// import the ader;
use PUGX\AOP\Aspect\LoggableGenerator;
use PUGX\AOP\DependencyInjection\Compiler\Symfony2;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
use PUGX\AOP\Aspect\Loggable;
use Doctrine\Common\Annotations\AnnotationRegistry;
// integrate autoloading with composer and annotations mapping
$loader = R . 'proxy/';
php
// Enable the Loggable aspect for all classes in the container that has @Log annotation
$symfony2Compiler = new Symfony2(new AnnotationReader(), $proxyDir, '\PUGX\AOP\Aspect\BaseAnnotation', array('loggable'));
$container->addCompilerPass($symfony2Compiler);
$container->compile();
php
namespace Example;
// import the Loggable aspect as Log
use PUGX\AOP\Aspect\Loggable\Annotation as Log;
class MyExampleClass
{
protected $a;
protected $b;
/**
* @Log(what="$a", when="start", with="monolog.logger_standard", as="Hey, Im getting %s as first argument")
*/
public function __construct($a, $b)
{
$this->a = $a;
$this->b = $b;
}
/**
* @Log(what="$c", when="start", with="monolog.logger_standard", as="argument $c is %s")
* @Log(what="$this->b", when="start", with="monolog.logger_standard", as="Hey, value of MyExampleClass::b is %s")
* @Log(what="$this->b", when="end", with="monolog.logger_standard", as="HOLY COW! Now MyExampleClass::b is %s")
* @\PUGX\AOP\Stub\MyAnnotation
*/
public function doSomething($c)
{
$this->b = $this->b * 10 + (int) $c;
}
}