okapi-web / php-aop

PHP-AOP is a library that adds aspect oriented programming capabilities to PHP.
https://github.com/okapi-web/php-aop
MIT License
31 stars 3 forks source link

Issues with Debugging #72

Closed djschilling closed 5 months ago

djschilling commented 9 months ago

When using this lib debugging gets harder. I cannot set a breakpoint in a File that gets proxied from this lib.

Can this be improved? I am using PHPStorm.

WalterWoshid commented 9 months ago

That's weird, for me it worked. I am using PhpStorm as well. Can you tell me what PhpStorm version you are using and your OS?

djschilling commented 9 months ago

PhpStorm 2023.3.2 MacOS: Sonoma 14.1.1 (23B81)

My Debugging Settings:

Bildschirmfoto 2024-01-09 um 09 45 53

I can step into the library Code and eventually come to the proxied file, but that is very complicated.

Maybe the cacheDir is the problem? This is how my kernel looks like:

<?php

namespace Churchtools\Lib\Aop;

use Churchtools\Lib\Config\Environment;
use Okapi\Aop\AopKernel;

class CTAopKernel extends AopKernel {
    protected array $aspects = [];

    protected function preInit(): void {
        $this->cacheDir = sys_get_temp_dir() . '/ct-aop-cache/' . BUILD_VERSION;
        parent::preInit();
    }

    protected function configureOptions(): void {
        $this->environment = Environment::isLocal()
            ? \Okapi\CodeTransformer\Core\Options\Environment::DEVELOPMENT
            : \Okapi\CodeTransformer\Core\Options\Environment::PRODUCTION;
    }
}
WalterWoshid commented 9 months ago

I'll check it out. Can you also tell me in if the file you're trying to debug the line number of the breakpoint corresponds to the same line number in the proxy file? For example echo "Hello"; on line 27 should have the same code in the proxy on line 27.

WalterWoshid commented 9 months ago

I see what the problem is, cached files return the path to their location while non-cached files are passed through the StreamFilter WITH their original file path. I have to route all files through the StreamFilter first and then it should work

Just to make sure this is not a MacOS problem, could you delete your cache directory and test if the very first run of your code debugs the original file?

djschilling commented 9 months ago

Just tested it. Without the cache it is working.

djschilling commented 9 months ago

Any updates here? Would be really good if debugging would work properly.

WalterWoshid commented 5 months ago

Hi @djschilling,

sorry for the late reply, had some health problems I needed to take care of first.

I fixed it and tested it on Windows, let me know if this works for you :)