xDebug-Toggler icon indicating copy to clipboard operation
xDebug-Toggler copied to clipboard

Valet restart

Open piperone opened this issue 4 years ago • 6 comments

Thanks for this really nifty little tool! I found it through the Laravel newsletter.

I have a bit of an issue. I use Laravel Valet for local development. I have Xdebug installed (the ext-xdebug.ini-file inside conf.d, etc) and it works fine. However, if I disable xdebug using the toggler and then re-enable it, xdebug appears not to be enabled. Even checking "--all" for which services to restart, xdebug is not active again until I run valet restart. I don't know why this is the case.

One possible solution to this, would be adding an option for a "custom command" to run after toggling (instead of the brew services commands). Just a thought.

Thanks again.

piperone avatar Jul 07 '20 02:07 piperone

Hi, I'm glad you like xDebugToggler.

This is a kind of a known issue. Sometimes even running valet restart is not enough, PhpStorm also needs to be restarted.

For the next version; running commands with sudo and/or custom commands will be the first priority.

Thanks for noticing.

deligoez avatar Jul 07 '20 18:07 deligoez

A restart valet option would be nice.

incon avatar Jul 10 '20 03:07 incon

Hello,

I've just discovered this wonderful little tool and this exact issue is cropping up!

Valet requires that the php services is run by root and not the user, so when this tool tries to restart the brew service it doesn't use sudo or valet restart

Really hoping at some stage this might be incorporated!

Thank you very much @deligoez

jonnywilliamson avatar Dec 14 '20 23:12 jonnywilliamson

https://developer.apple.com/forums/thread/91350 https://developer.apple.com/forums/thread/99151

Of course, having looked into this a little, it appears nothing will be easy! 🙄

jonnywilliamson avatar Dec 14 '20 23:12 jonnywilliamson

Hi Everybody,

Thanks for your suggestions.

Before diving into running sudo commands from swift. I think I found a quick way to restart valet.

valet has a trust command which makes valet commands run without root user password.

I'll start to implement this today.

deligoez avatar Dec 15 '20 06:12 deligoez

Is this project maintained anymore? Really would like it to include valet restart. In the meantime you can just add this to your ~/.bashrc or ~/.zshrc file. Then you'll be able to turn on/off xdebug from the terminal

# Enabled/Disable valet php xdebug extension.
function valet:xdebug() {
  STATE="${1:?Missing argument, pass either on|off.}"
  PHP_EXT_XDEBUG="/usr/local/etc/php/7.4/conf.d/ext-xdebug.ini"
  
  if [[ $STATE == "on" && -f "$PHP_EXT_XDEBUG.disabled" ]]; then
    mv "$PHP_EXT_XDEBUG.disabled" $PHP_EXT_XDEBUG
  fi 
  
  if [[ $STATE == "off" && -f $PHP_EXT_XDEBUG ]]; then
    mv $PHP_EXT_XDEBUG "$PHP_EXT_XDEBUG.disabled" 
  fi
  
  valet restart php
}

Then re-source using source ~/.zshrc , now when you type valet:xdebug on|off it should enable|disable xdebug and then do a valet restart php.

droath avatar Mar 29 '22 03:03 droath