sumeetpareek / wordpress-one-and-half-days

I have been a full stack software engineer, primarily focused on drupal, for over 10 years. Goal of this project is to spend 1.5 days to see what is going on in wordpress ecosystem 😃
0 stars 0 forks source link

As seasoned drupal developer resurrecting wordpress — I want to run and debug wordpress via a local development environment — so I can have the setup used by wordpress core and plugin developers #2

Open sumeetpareek opened 3 years ago

sumeetpareek commented 3 years ago

TASK ⚠️ from end user perspective ⚠️

As seasoned drupal developer resurrecting wordpress — I want to run and debug wordpress via a local development environment — so I can have the setup used by wordpress core and plugin developers

DONE WHEN

CHECKLIST

sumeetpareek commented 3 years ago

there is community developer documentation on using various methods going ahead with vvv vagrant setup image

looks like I was on really old versions .. will quickly try to update

VirtualBox -h                                                                                                                                                                                                                              
Oracle VM VirtualBox Manager 5.1.28
# latest is 6.1.22

vagrant --version                                                                                                                                                                                                                          
Vagrant 2.0.0
# latest is 2.1.16

updated virtualbox and vagrant ..

⚠️ error on installing vagrant-hostsupdater plugin

and installed hostupdated plugin

vagrant plugin install vagrant-hostsupdater                                                                                                                                                                                             

Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
Fetching vagrant-auto_network-1.0.3.gem
Fetching vagrant-hostmanager-1.8.9.gem
Fetching vagrant-hostsupdater-1.2.4.gem
Fetching micromachine-3.0.0.gem
Fetching vagrant-vbguest-0.29.0.gem
Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

Unable to resolve dependency: user requested 'vagrant-auto_network (= 1.0.2)'

trying to expunge all plugins ... it worked

vagrant plugin expunge --reinstall

https://github.com/hashicorp/vagrant/issues/8054

sudo vagrant plugin install vagrant-hostsupdater                                                                                                                                                                                          

Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostsupdater (1.2.4)'!

following VVV instructions https://varyingvagrantvagrants.org/docs/en-US/installation/

git clone -b stable https://github.com/Varying-Vagrant-Vagrants/VVV.git ~/vvv-local
cd ~/vvv-local
vagrant plugin install --local

trying to get everything and have it up 🤞

vagrant up

got everything working ... now to step through the code and change something image

sumeetpareek commented 3 years ago

found default credentials here https://varyingvagrantvagrants.org/docs/en-US/default-credentials/ was able to login as admin in site one

sumeetpareek commented 3 years ago

activated the hello dolly plugin appended a test string to the return value of hello_dolly_get_lyric() and it worked 👍

installed and activated the WP maintenance mode plugin https://wordpress.org/plugins/wp-maintenance-mode/ tried various settings of it and it works

image

sumeetpareek commented 3 years ago

trying to turn on debugger > setup break points > and step through execution opened wordpress code base in phpstrom

cd github/vvv-local/www/wordpress-one/public_html
pstorm .

will follow this https://varyingvagrantvagrants.org/docs/en-US/references/xdebug-and-phpstorm/

confirmed in phpinfo that xdebug is not active yet http://vvv.test/phpinfo/

enabled xdebug with php restart vagrant ssh -c "switch_php_debugmod xdebug"

edited phpstorm settings

confirmed project root in directory settings
php language level set to 7.4
added include path to /Users/sumeetpareek/github/vvv-local/www/wordpress-one/public_html
Run > Edit configurations
added new PHP Remote Debug
filtered by IDE key set to VVVDEBUG

🚫 error .. phpstorm xdebug server setup

there is no server in the server drop down and apply button says server must be selected manually setting server like this did not help all attempts failed https://blog.jetbrains.com/phpstorm/2016/06/debugging-vvv-vagrant-setup-with-phpstorm/ https://varyingvagrantvagrants.org/docs/en-US/references/xdebug-and-phpstorm/ https://cnpagency.com/blog/debugging-wordpress-on-vvv-with-phpstorm/

found out that vvv has a new xdebug info button http://vvv.test/xdebuginfo/ seems like the setup has moved to xdebug 3.0.3 which had another helpful blog https://www.seanhayes.biz/vvv-and-xdebug-3-using-improved-xdebug-with-varying-vagrant-vagrants-and-phpstorm/

ran the debug validation script confirmed problem reported in above blog .. fixing it with the recommended config changes in VVVROOT/config/php-config/xdebug.ini image

changed phpstorm PHP xdebug port from 9000 to 9003 appended to xdebug config.ini

xdebug.client_host =192.168.50.1
xdebug.mode =debug

reloaded vagrant and provisioned again vagrant reload --provision

none of the wordpress site or vvv dashboard was accessible ... halted and up-ed vagrant again

the change in client host did not work image

trying to undo it and just leave things where phpstorm port is set to 9003

even with all of this .. now the debugger connects .. but it never stops at any breakpoint .. even if break at first line is enabled

image

sumeetpareek commented 3 years ago

✅ debugger finally worked, yaaas

after lots of trails and errors .. xdebug + phpstorm + vvv worked

image


and we can inspect plugins, actions, hooks, and all of the stuff now image