Go! AOP: Declarative behaviors for PHP
Keep your business logic clean. Make your methods powerful. Go! AOP attaches reusable behaviors to any method of your application — logging, caching, transactions, authorization, audit and more — without changing your original code. You write a behavior once, in an ordinary PHP class, and say where it applies: with an attribute on a method or with a matching rule. The framework then applies it as dynamic middleware around every selected method when PHP loads the class.
Define such behaviors once, and apply them automatically everywhere they are needed. Your business logic stays
clean, your infrastructure code stays organized.

👀 At a glance
Your class carries only its business logic and, if you like, an attribute of your own:
use App\Attribute\Transactional;
final class OrderService
{
#[Transactional]
public function placeOrder(Order $order): void
{
// business logic only
}
}
The behavior lives in a behavior class (an aspect, in the API) and runs around every method that carries the
attribute:
use App\Attribute\Transactional;
use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Attribute\Around;
final class TransactionAspect implements Aspect
{
public function __construct(private readonly \PDO $connection) {}
#[Around('@execution(App\Attribute\Transactional)')]
public function inTransaction(MethodInvocation $invocation): mixed
{
$this->connection->beginTransaction();
try {
$result = $invocation->proceed();
$this->connection->commit();
return $result;
} catch (\Throwable $exception) {
$this->connection->rollBack();
throw $exception;
}
}
}
Register the behavior class in the kernel once (see Installation), and every method marked
#[Transactional] runs in a transaction. OrderService keeps its name, its final declaration and its type: there
is no wrapper object and no decorator to wire.
✨ Features
🔌 Zero Extensions, Pure PHP
-
No PECL/PIE extensions required — Forget about php-aop, runkit, uopz, or any other low-level extensions. Go! AOP is written in 100% pure PHP — just composer require and you're ready. No compilation, no system dependencies, no deployment headaches.
-
Zero eval() calls — Your architecture team will love this. The framework never uses eval() or create_function() for dynamic code execution. Applying behaviors produces static PHP files that can be reviewed, scanned by security tools, and audited. No hidden code generation at runtime.
-
PHPStan Level 10 — The entire codebase passes PHPStan's strictest analysis level — maximum type safety, no mixed types escaping, full type-aware support. This means fewer bugs, better IDE autocompletion, and confidence that the framework won't introduce type errors into your application.
🎯 Powerful Interception Capabilities: attach behaviors anywhere
The framework provides powerful core interception capabilities that hook your behaviors into almost any place in
your application — even into the methods PHP won't let you override: