andreaswolf / fractor

Generic File Read-Analyze-Change Tool
MIT License
33 stars 0 forks source link

Run fractor in "standalone" directory #233

Open wtfred opened 1 week ago

wtfred commented 1 week ago

Hello there,

Sorry in advance if i'm doing something wrong here. I'm updating my "template" for TYPO3 project, with all dev tools i'm using, and i want to start using Fractor.

Running into this issue with typo3-rector, i moved dev tools from my project composer dev dependencies to standalone directories, as i was advised in the issue, and also in the recommanded way of php-cs-fixer

I tried to do the same thing with Fractor, and install it in a standalone directory, but when i try to run it, i got this error:

PHP Fatal error:  Uncaught Error: Class "a9f\Fractor\Configuration\ConfigResolver" not found in /var/www/html/.tools/fractor/vendor/a9f/fractor/bin/fractor.php:29

From what i understand, it comes from this line https://github.com/andreaswolf/fractor/blob/main/packages/fractor/bin/fractor.php#L12 that makes the binary loading my project autoload first, and not the autoload from the "standalone directory"

Once again, sorry if i'm doing something wrong, i'm starting to use both Fractor and this standalone directory method both together so...

Thanks!

wtfred commented 1 week ago

A bit more info on this issue, and i also found a workaround.

In my project directory, i have a tools folder, like this:

tools/fractor
tools/typo3-coding-standards
tools/typo3-rector

To execute rector, i can do tools/typo3-rector/vendor/bin/rector process --dry-run To execute phpstan, i can do tools/typo3-rector/vendor/bin/phpstan To execute php-cs-fixer, i can do tools/typo3-coding-standards/vendor/bin/php-cs-fixer check

If i try to run fractor with tools/fractor/vendor/bin/fractor process --dry-run, i got the error mentioned above

As a workaround, i have to do this:

cd tools/fractor
vendor/bin/fractor process --dry-run -c ../../fractor.php