Una lente de aumento revela una estructura cian dentro de capas de vidrio apiladas.
Funcionalidad · Depurable

Nada de magia que no puedas recorrer paso a paso.

Código generado no debería significar comportamiento oculto. El framework produce PHP legible que puedes inspeccionar, comparar, depurar y recorrer paso a paso con tus herramientas de siempre.

Tu clase y lo que realmente se ejecuta

Un servicio de informes con un comportamiento de caché y los dos archivos que el framework escribe para él. Son los archivos reales de la sesión que puedes recorrer paso a paso más abajo.

Tu código

Un comportamiento de caché se aplica con #[Cacheable]. Este es el archivo que abres, lees y en el que pones breakpoints.

ReportService.phptu código

        
        
        <?php
        
        
        
      
        
        
         
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
         
        
        
        
      
        
        
        namespace App\Report;
        
        
        
      
        
        
         
        
        
        
      
        
        
        use App\Attribute\Cacheable;
        
        
        
      
        
        
         
        
        
        
      
        
        
        class ReportService
        
        
        
      
        
        
        {
        
        
        
      
        
        
            public function __construct(private OrderRepository $orders) {}
        
        
        
      
        
        
         
        
        
        
      
        
        
            #[Cacheable(ttl: 300)]
        comportamiento de caché aplicado
        
        
      
        
        
            public function monthlyRevenue(string $month): int
        
        
        
      
        
        
            {
        
        
        
      
        
        
                $total = 0;
        aquí salta un breakpoint
        
        
      
        
        
                foreach ($this->orders->forMonth($month) as $order) {
        
        
        
      
        
        
                    $total += $order->cents;
        
        
        
      
        
        
                }
        
        
        
      
        
        
         
        
        
        
      
        
        
                return $total;
        
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      

Código compilado

El cuerpo de tu clase como un trait. Solo cambia la línea de la declaración, así que cada número de línea se mantiene. En modo debug, PHP lo carga bajo tu ruta original, así que el depurador se detiene en src/Report/ReportService.php.

ReportServiceOriginalTrait.phpcompilado

        
        
        <?php
        
        
        
      
        
        
         
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
         
        
        
        
      
        
        
        namespace App\Report;
        
        
        
      
        
        
         
        
        
        
      
        
        
        use App\Attribute\Cacheable;
        
        
        
      
        
        
         
        
        
        
      
        
        
        trait ReportServiceOriginalTrait
        era: class ReportService
        
        
      
        
        
        {
        
        
        
      
        
        
            public function __construct(private OrderRepository $orders) {}
        
        
        
      
        
        
         
        
        
        
      
        
        
            #[Cacheable(ttl: 300)]
        
        
        
      
        
        
            public function monthlyRevenue(string $month): int
        
        
        
      
        
        
            {
        
        
        
      
        
        
                $total = 0;
        
        
        
      
        
        
                foreach ($this->orders->forMonth($month) as $order) {
        
        
        
      
        
        
                    $total += $order->cents;
        
        
        
      
        
        
                }
        
        
        
      
        
        
         
        
        
        
      
        
        
                return $total;
        
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      
        
        
        include_once AOP_CACHE_DIR . '/Report/ReportService.php';
        
        
        
      

Clase proxy

La clase que carga PHP, con el nombre de tu clase, así que las trazas de la pila nombran ReportService. El middleware es un único método legible: construye el joinpoint una vez y luego lo ejecuta.

ReportService.phpgenerado

        
        
        <?php
        
        
        
      
        
        
        declare(strict_types=1);
        
        
        
      
        
        
        namespace App\Report;
        
        
        
      
        
        
         
        
        
        
      
        
        
        use Go\Aop\Framework\InterceptorInjector;
        
        
        
      
        
        
        use Go\Aop\Framework\Interceptor;
        
        
        
      
        
        
        use Go\Aop\Framework\The;
        
        
        
      
        
        
        use App\Aspect\CachingAspect;
        
        
        
      
        
        
        use Go\Aop\Intercept\DynamicMethodInvocation;
        
        
        
      
        
        
        use App\Attribute\Cacheable as Cacheable;
        
        
        
      
        
        
        class ReportService implements \Go\Aop\Proxy
        el nombre de tu clase
        
        
      
        
        
        {
        
        
        
      
        
        
            use ReportServiceOriginalTrait {
        el cuerpo de tu clase
        
        
      
        
        
                ReportServiceOriginalTrait::monthlyRevenue as private monthlyRevenueOriginalAlias;
        
        
        
      
        
        
            }
        
        
        
      
        
        
            #[\App\Attribute\Cacheable(ttl: 300)]
        
        
        
      
        
        
            public function monthlyRevenue(string $month): int
        
        
        
      
        
        
            {
        
        
        
      
        
        
                /** @var DynamicMethodInvocation<self, int> $__joinPoint */
        
        
        
      
        
        
                static $__joinPoint = InterceptorInjector::forMethod(
        se crea en la primera llamada
        
        
      
        
        
                    self::class,
        
        
        
      
        
        
                    'monthlyRevenue',
        
        
        
      
        
        
                    [
        
        
        
      
        
        
                        Interceptor::around(The::aspect(CachingAspect::class)->cache(...)),
        Ctrl-clic abre CachingAspect::cache()
        
        
      
        
        
                    ],
        
        
        
      
        
        
                    $this->monthlyRevenueOriginalAlias(...),
        tu método original
        
        
      
        
        
                );
        
        
        
      
        
        
                return $__joinPoint->__invoke($this, [$month]);
        ejecuta el middleware
        
        
      
        
        
            }
        
        
        
      
        
        
        }
        
        
        
      

Depúralo como código que escribiste tú

Una sesión de depuración real de la misma clase, grabada y reproducida en tu navegador. Entra en la llamada, pon breakpoints en el margen, abre cualquier frame. La guía explica qué ocurre en cada paso.

Debug: php bin/report.phpreplay
bin/report.php
<?php
declare(strict_types=1);
use App\Report\OrderRepository;
use App\Report\ReportService;
require dirname(__DIR__) . '/bootstrap.php';
$reports = new ReportService(new OrderRepository());
foreach (['2026-10', '2026-10'] as $month) {
$start = hrtime(true);
$cents = $reports->monthlyRevenue($month);
printf("%s: %d cents in %.2f ms\n", $month, $cents, (hrtime(true) - $start) / 1e6);
}

Frames

    Variables

    Console timed under the debugger

    stop 1 of 84

    Desde la consola

    Pregúntale al compilador qué ha hecho

    La consola que viene con el framework responde preguntas sobre tu kernel: qué clases de comportamiento tiene y a qué llega cada una. También compila la caché por adelantado. Recorre los comandos; el terminal muestra su salida real para la app de arriba.

    1. Run the app

      php bin/report.php

      The same app, without the debugger. The first call runs the slow query; the second comes from the caching behavior in a hundredth of a millisecond.

    2. List the behavior classes

      vendor/bin/aspect debug:aspect bootstrap.php

      Every behavior class (an aspect, in the API) your kernel registers, the file it is defined in, and the advisors it declares. The loader file only boots the kernel; it must not handle a request.

    3. List the advisors

      vendor/bin/aspect debug:advisor bootstrap.php

      Each advisor with its pointcut. Here there is one: cache(), for every method marked #[Cacheable].

    4. See what an advisor reaches

      vendor/bin/aspect debug:advisor bootstrap.php --advisor='App\Aspect\CachingAspect->cache'

      Analyzes every file below the include paths and lists the members the advisor matches: monthlyRevenue(), and nothing else.

    5. Weave ahead of time

      vendor/bin/aspect cache:warmup:aop bootstrap.php

      Weaves every file at deploy time, so production serves the prebuilt cache. It fails when a file can’t be woven; --workers=8 weaves in parallel.

    Terminalrecorded
    php bin/report.php
    2026-10: 21199 cents in 156.16 ms
    2026-10: 21199 cents in 0.01 ms
    vendor/bin/aspect debug:aspect bootstrap.php
    Aspect debug information
    ========================
    
     App\AppKernel has following enabled aspects:
    
    App\Aspect\CachingAspect
    ------------------------
    
    Defined in: /app/src/Aspect/CachingAspect.php
    Pointcuts and advices
     --------- ---------------------------------
      Type      Identifier
     --------- ---------------------------------
      Advisor   App\Aspect\CachingAspect->cache
     --------- ---------------------------------
    vendor/bin/aspect debug:advisor bootstrap.php
    Advisor debug information
    =========================
    
    List of registered advisors in the container
     --------------------------------- -------------------------------------
      Id                                Expression
     --------------------------------- -------------------------------------
      App\Aspect\CachingAspect->cache   @execution(App\Attribute\Cacheable)
     --------------------------------- -------------------------------------
    
    If you want to query an information about concrete advisor, then just query it
    by adding --advisor="Advisor\Name" to the command
    vendor/bin/aspect debug:advisor bootstrap.php --advisor='App\Aspect\CachingAspect->cache'
    Advisor debug information
    =========================
    
    Total 6 files to analyze.
      -> matching method App\Report\ReportService->monthlyRevenue
    vendor/bin/aspect cache:warmup:aop bootstrap.php
    Total 6 files to process.
    
    [DONE]: Total processed 6, 0 errors in 5 ms.

    Crea comportamientos. Mantén todo depurable.

    La mayoría de los frameworks te piden que confíes en la magia. Aquí puedes abrir, inspeccionar y recorrer paso a paso cada línea que se ejecuta.