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

Generic PHP Debug Mod Switcher #2084

Merged
merged 5 commits into from
Mar 14, 2020
Merged

Generic PHP Debug Mod Switcher #2084

merged 5 commits into from
Mar 14, 2020

Conversation

tomjn
Copy link
Member

@tomjn tomjn commented Mar 14, 2020

Summary:

When we tried to add pcov, it wasn't until afterwards I realised it wasn't compatible with XDebug, it seems they all need a particular handler installed, but PHP will only use 1 of them.

To prevent the proliferation of xdebug_on xdebug_off tideways_on tideways_off pcov_on pcov_off etc etc, I've written a switcher script that includes some improvements:

  • You can pass none and it will return you to vanilla PHP
  • It will disable everything then enable what you wanted
  • It won't try to disable things that aren't enabled
  • It sets the pipefail etc options
  • Reduces duplication across every script by having just one script

Here's what it looks like in action:

vagrant@vvv:~$ switch_php_debugmod xdebug
 * Disabling active debug PHP mods
 * Disabling if present: 'xdebug, xhgui, tideways_xhprof, pcov'
 * Disabling active module: 'xdebug'
 * Enabling 'xdebug'
 * Restarting PHP FPM's so the change takes effect
vagrant@vvv:~$ 

Screenshot 2020-03-14 at 16 28 19

There are some future improvements that can be made:

  • It doesn't need to disable the thing that's being enabled, in the above example it disables everything then enables xdebug, but if xdebug is already enabled it should see that and just disable the others
  • I'd like to be able to detect when you're activating something that doesn't exist, at the moment it generates a warning which is a bit unsightly. E.g:
vagrant@vvv:~$ switch_php_debugmod bananas
 * Disabling active debug PHP mods
 * Disabling if present: 'xdebug, xhgui, tideways_xhprof, pcov'
 * Disabling active module: 'xdebug'
 * Enabling 'bananas'
WARNING: Module bananas ini file doesn't exist under /etc/php/7.2/mods-available
WARNING: Module bananas ini file doesn't exist under /etc/php/7.2/mods-available
 * Restarting PHP FPM's so the change takes effect
vagrant@vvv:~$ 

Checks

  • I've tested this PR with Vagrant v2.2.7 and VirtualBox v6.1 on MacOS Catalina
  • This PR is for the develop branch not the master branch.
  • I've updated the changelog.
  • This PR is complete and ready for review.

@update-docs
Copy link

update-docs bot commented Mar 14, 2020

Thanks for opening this pull request! Make sure CHANGELOG.md gets updated with this change, additionaly any docs that need updated can be found at https://github.com/Varying-Vagrant-Vagrants/varyingvagrantvagrants.org

GitHub
The VVV docs and website. Contribute to Varying-Vagrant-Vagrants/varyingvagrantvagrants.org development by creating an account on GitHub.

@tomjn tomjn added this to the 3.3 milestone Mar 14, 2020
@tomjn tomjn requested a review from a team March 14, 2020 16:44
Copy link
Member

@Mte90 Mte90 left a comment

Choose a reason for hiding this comment

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

tested and works

@Mte90
Copy link
Member

Mte90 commented Mar 14, 2020

I don't know if it is the case to merge also with the support to check if themodule exists.

@tomjn
Copy link
Member Author

tomjn commented Mar 14, 2020

@Mte90 we don't check for that at the moment, I'm not 100% sure of how we should go about doing that anyway, as php -m etc only tell us if it's active. We could look in the mods available folder, but I don't know that's 100% foolproof

@tomjn tomjn merged commit 7d0f78c into develop Mar 14, 2020
@Mte90 Mte90 deleted the modify/phpswitchers branch April 8, 2020 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants