Intercept anythingPointcut playground

Write a rule. See what it matches.

Target code by name, visibility, return type or attributes. Edit the pointcut and PHP source, then see every match highlighted directly in the code.

Selects 12 joinpoints · 2 can’t be intercepted

Start with an example. Make it your own.

Playground.phpeditable

Selected joinpoints

This matcher runs in your browser and reads one file, following the documented grammar. The weaver itself reflects your real classes, their parents and traits.

Pointcut cheat sheet

The forms the playground understands, from the framework's pointcut reference. Arguments are never matched: the argument list is always (*).

Pointcuts

execution(public App\Service->save(*))
Calls of an instance method
execution(public App\Service::create(*))
Calls of a static method
execution(App\Service\file_get_contents(*))
Calls of a PHP function from code in that namespace
access(public App\Entity\User->email)
Reads and writes of a property
within(App\Model\*)
Every method and property of the matching classes
initialization(App\Model\Order)
Object creation with new
staticinitialization(App\Model\*)
The first load of the matching classes
@execution(App\Attribute\Logged)
Methods that carry the attribute
@access(App\Attribute\Audited)
Properties that carry the attribute
@within(App\Attribute\Monitored)
Every member of classes that carry the attribute

Patterns and operators

*
Any characters of one name part, never crossing a \
**
Any namespace depth: App\** is every class below App
get*|is*
Alternatives within one name part
Foo+
Foo, its subclasses and implementers, and classes using the trait Foo
public|protected
Modifier alternatives; final, readonly, private(set) too
: App\Entity|null
Restrict the declared return type
&& || ! ( )
Combine, negate and group pointcuts
matchInherited()
Only members inherited or taken from a trait
Full pointcut reference
Attribute-driven

Define your own behavior attributes.

Create custom PHP attributes, attach behaviors to them, and mark only the methods that need them. Your application code stays framework-independent.

The IDEA plugin adds pointcut syntax highlighting and autocompletion directly inside your attributes.

src/Attribute/Transactional.phpyour code
#[\Attribute(\Attribute::TARGET_METHOD)]final class Transactional {}
src/Aspect/TransactionAspect.phptransactions
final class TransactionAspect implements Aspect{    #[Around('@execution(App\Attribute\Transactional) && !within(App\Legacy\**)')]    public function inTransaction(MethodInvocation $invocation): mixed    {        return $this->db->transactional(            fn () => $invocation->proceed()        );    }}
src/Order/OrderService.phpdomain
#[Transactional]public function placeOrder(Cart $cart): Order{    return $this->orders->create($cart);}