Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable xdebug automatically #325

Closed

Conversation

bepsvpt
Copy link

@bepsvpt bepsvpt commented Jan 2, 2025

This pull request addresses performance issues caused by the Xdebug extension being enabled during the execution of Pint. By incorporating the Composer\XdebugHandler\XdebugHandler class, the application will automatically restart without Xdebug unless the environment variable PINT_ALLOW_XDEBUG is set. This ensures that Pint runs without the performance overhead associated with Xdebug.

This fix might be related to the following issues: #309, #299 and #275.

Reference: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/ad0cc3078a93a8438edbc58e7e2094a8b38d7389/php-cs-fixer#L102-L105

@bepsvpt bepsvpt force-pushed the fix/disable-xdebug-automatically branch from 0243c86 to 8aa9a3d Compare January 2, 2025 15:01
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@mortenscheel
Copy link

mortenscheel commented Jan 3, 2025

This change gave a 10x performance improvement in my project (from 12 minutes to ~1 minute). See #309.

Might be worth reconsidering. If not, maybe add a note in the docs about setting XDEBUG_MODE=off when running pint.

Copy link

@Zen0x7 Zen0x7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea behind this good, but the code doesn't reflect the goal of what pretend to be fixed.

Take my comments as contribution, i'm not contributor at all.

Comment on lines +3 to +15
/*
|--------------------------------------------------------------------------
| Restart If Xdebug Is Loaded
|--------------------------------------------------------------------------
|
| If the Xdebug extension is loaded, the application will automatically
| restart unless the environment variable PINT_ALLOW_XDEBUG is set. This
| ensures the application runs without the performance overhead of Xdebug.
|
*/

(new Composer\XdebugHandler\XdebugHandler('PINT'))->check();

Copy link

@Zen0x7 Zen0x7 Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want update the bootstrap file, probably you'll need to design a contract for it.

Think about the idea of create a instance just to run one method and after that, release it into the void.

If you read more forward or deep, you'll understand that they bind classes to contracts.

Comment on lines 25 to 27
"require-dev": {
"composer/xdebug-handler": "^3.0.5",
"friendsofphp/php-cs-fixer": "^3.66.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a dependency can be convenient but the source must be trustfully.

Of course, composer is safe but is necessary?

The more decoupled and independent something is, the better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants