A white beam passes straight through a clear glass block with a soft red rim light.
Feature · Pure PHP

No extensions. No black boxes. Just PHP.

The framework works with Composer and generates ordinary PHP files with your behaviors attached. Read them, debug them and run them with the tools you already use.

No PHP extension

The compiler is written in PHP.

The framework works as an ordinary Composer package. It parses your classes, matches them against your rules and generates new PHP source with the behaviors attached. No custom extension to install, enable or rebuild.

In development, classes are woven when they are first loaded. In production, compile them once during deployment or image build using cache:warmup:aop. Requests simply include the generated PHP files.

  • No custom extension — only PHP's built-in tokenizer extension is required.
  • No rebuilds after PHP upgrades — just install compatible Composer dependencies and warm up the cache.
  • Same compiler everywhere — development, CI and production.
  • Read-only production — prebuilt generated files can run from a read-only filesystem.
index.phpproduction

        
        
        <?php
        
        
        
      
        
        
         
        
        
        
      
        
        
        use Go\Aop\Features;
        
        
        
      
        
        
         
        
        
        
      
        
        
        include __DIR__ . '/../vendor/autoload.php';
        
        
        
      
        
        
         
        
        
        
      
        
        
        ApplicationAspectKernel::getInstance()->init([
        
        
        
      
        
        
            'debug'        => false,
        
        
        
      
        
        
            'appDir'       => __DIR__ . '/..',
        
        
        
      
        
        
            'cacheDir'     => __DIR__ . '/../var/cache/aop',
        
        
        
      
        
        
            'includePaths' => [__DIR__ . '/../src'],
        
        
        
      
        
        
            'features'     => Features::PREBUILT_CACHE,
        
        
        
      
        
        
        ]);
        
        
        
      
Terminaldeploy

        
        
        # install: the weaver is a Composer package
        
        
        
      
        
        
        composer require goaop/framework
        
        
        
      
        
        
        # deploy: weave the whole cache once
        
        
        
      
        
        
        vendor/bin/aspect cache:warmup:aop public/index.php
        
        
        
      
No eval()

Generated PHP, loaded like any other file.

The framework generates PHP source instead of executing code from strings. Each woven class produces two files in the cache, loaded through PHP's standard include. OPcache handles them like any other PHP file — and every generated line remains open for inspection and debugging.

Your source

A transaction behavior is attached to placeOrder(). Your file stays exactly as you wrote it.

OrderService.phpyour code

        
        
        <?php
        
        
        
      
        
        
         
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
         
        
        
        
      
        
        
        namespace App\Order;
        
        
        
      
        
        
         
        
        
        
      
        
        
        final class OrderService
        
        
        
      
        
        
        {
        
        
        
      
        
        
            public function __construct(
        
        
        
      
        
        
                private readonly OrderRepository $orders,
        
        
        
      
        
        
            ) {}
        
        
        
      
        
        
         
        
        
        
      
        
        
            public function placeOrder(Cart $cart): Order
        
        
        
      
        
        
            {
        
        
        
      
        
        
                return $this->orders->create($cart);
        
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      

Woven source

Your class body, as the trait OrderServiceOriginalTrait. Only the declaration line changes, so line numbers match and Xdebug breakpoints still fire. One added line loads the proxy.

OrderServiceOriginalTrait.phpwoven

        
        
        <?php
        
        
        
      
        
        
         
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
         
        
        
        
      
        
        
        namespace App\Order;
        
        
        
      
        
        
         
        
        
        
      
        
        
        trait OrderServiceOriginalTrait
        was: final class OrderService
        
        
      
        
        
        {
        
        
        
      
        
        
            public function __construct(
        
        
        
      
        
        
                private readonly OrderRepository $orders,
        
        
        
      
        
        
            ) {}
        
        
        
      
        
        
         
        
        
        
      
        
        
            public function placeOrder(Cart $cart): Order
        
        
        
      
        
        
            {
        
        
        
      
        
        
                return $this->orders->create($cart);
        
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      
        
        
        include_once AOP_CACHE_DIR . '/src/Order/OrderService.php';
        
        
        
      

Proxy class

The class PHP loads: your class name, still final, using the trait. Each method with a behavior runs it as middleware, then calls your original method through a private alias.

OrderService.phpgenerated

        
        
        <?php
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
        namespace App\Order;
        
        
        
      
        
        
        use Go\Aop\Framework\InterceptorInjector;
        
        
        
      
        
        
        use Go\Aop\Framework\Interceptor;
        
        
        
      
        
        
        use Go\Aop\Framework\The;
        
        
        
      
        
        
        use Go\Aop\Intercept\DynamicMethodInvocation;
        
        
        
      
        
        
        use App\Aspect\TransactionAspect;
        
        
        
      
        
        
        final class OrderService implements \Go\Aop\Proxy
        same name, still final
        
        
      
        
        
        {
        
        
        
      
        
        
            use OrderServiceOriginalTrait {
        your class body
        
        
      
        
        
                OrderServiceOriginalTrait::placeOrder as private placeOrderOriginalAlias;
        
        
        
      
        
        
            }
        
        
        
      
        
        
            public function placeOrder(\App\Order\Cart $cart): \App\Order\Order
        
        
        
      
        
        
            {
        
        
        
      
        
        
                /** @var DynamicMethodInvocation<self, \App\Order\Order> $__joinPoint */
        typed for PHPStan and IDEs
        
        
      
        
        
                static $__joinPoint = InterceptorInjector::forMethod(
        
        
        
      
        
        
                    self::class,
        
        
        
      
        
        
                    'placeOrder',
        
        
        
      
        
        
                    [
        
        
        
      
        
        
                        Interceptor::around(The::aspect(TransactionAspect::class)->inTransaction(...)),
        Ctrl-click opens the behavior
        
        
      
        
        
                    ],
        
        
        
      
        
        
                    $this->placeOrderOriginalAlias(...),
        your original method
        
        
      
        
        
                );
        
        
        
      
        
        
                return $__joinPoint->__invoke($this, [$cart]);
        
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      
Static PHP files

Object-oriented code that PHPStan understands

The woven code is classes and traits with typed signatures, with no magic methods in between. Each joinpoint carries a generic docblock, so PHPStan and your IDE know that $__joinPoint->__invoke() returns an Order, even inside the cache directory.

  • Your class name, final keyword and typed signatures are kept
  • Everything that runs is a file in the cache, with no __call() indirection
  • Joinpoints declare @template types, e.g. MethodInvocation<OrderService, Order>
  • Cache paths mirror your source, so reviewers and scanners find every file
OrderService.phptype info

        
        
            public function placeOrder(\App\Order\Cart $cart): \App\Order\Order
        
        
        
      
        
        
            {
        
        
        
      
        
        
                /** @var DynamicMethodInvocation<self, \App\Order\Order> $__joinPoint */
        
        
        
      
        
        
                static $__joinPoint = InterceptorInjector::forMethod(
        
        
        
            static $__joinPoint
            DynamicMethodInvocation<OrderService, Order>__invoke(…): Order
            From the @var docblock in the woven file
          
      
        
        
                    self::class,
        
        
        
      
        
        
                    'placeOrder',
        
        
        
      
        
        
                    [
        
        
        
      
        
        
                        Interceptor::around(The::aspect(TransactionAspect::class)->inTransaction(...)),
        
        
        
      
        
        
                    ],
        
        
        
      
        
        
                    $this->placeOrderOriginalAlias(...),
        
        
        
      
        
        
                );
        
        
        
      
        
        
                return $__joinPoint->__invoke($this, [$cart]);
        
        
        
      
        
        
            }
        
        
        
      
Projectcache directory

        
        
        var/cache/aop/
        
        
        
      
        
        
        ├── _include.cache                         # class map for Composer
        
        
        
      
        
        
        └── src/
        
        
        
      
        
        
            ├── Aspect/
        
        
        
      
        
        
            │   └── TransactionAspect.cache.php    # compiled pointcuts of the behavior
        
        
        
      
        
        
            └── Order/
        
        
        
      
        
        
                ├── OrderService.php               # proxy class
        
        
        
      
        
        
                └── OrderServiceOriginalTrait.php  # your class body
        
        
        
      

The woven method calls your behavior directly, as a first-class callable, so your IDE can jump to it. Details in the README.