Difference between revisions of "PHP Mediawiki Eclipse debugging"

From BITPlan Wiki
Jump to navigation Jump to search
Line 99: Line 99:
  
 
Enable composer in Project's properties
 
Enable composer in Project's properties
 +
There should be only some 20 errors and 60 warnings. Mostly the errors are XMLProblems and ComposerHook ComposerPack issues which are hopefully not relevant.
 +
== Debugging ==
 +
Set your breakpoints e.g. in the code of an extension.
 +
Then click index.php and right click "Run Debug as PHP Web Application". You'll be asked for the URL to debug
 +
[[File:debugdialog2020-02-09.png|400px]]
  
 
= Add Extension to debug=
 
= Add Extension to debug=

Revision as of 16:24, 9 February 2020

Trying to get https://www.semantic-mediawiki.org/wiki/User:WolfgangFahl/Workdocumentation_2015-12-27 working again

Environment

  • LAMP Intranet MediaWiki 1.33 with no security needs in a VMWare environment
lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.4 LTS
Release:	18.04
Codename:	bionic
apachectl -V
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2019-09-16T12:58:48
mysql --version
mysql  Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using  EditLine wrapper
php --version
PHP 7.2.24-0ubuntu0.18.04.2 (cli) (built: Jan 13 2020 18:39:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies

Install eclipse php

cd /usr/local/src
# download eclipse-php-2019-12-R-linux-gtk-x86_64.tar.gz  from
# https://www.eclipse.org/downloads/
sudo tar xvfz eclipse-php-2019-12-R-linux-gtk-x86_64.tar.gz

Desktop icon

~/Desktop$ cat eclipse.desktop 
[Desktop Entry]
Type=Application
Terminal=false
Name=Eclipse
Exec=/usr/local/src/eclipse/eclipse
Comment=Eclipse 2019 Integrated development environment
Icon=/usr/local/src/eclipse/icon.xpm
StartupWMClass=Eclipse

Install Mediawiki

see https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu

sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring
/usr/local/src$ sudo wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.2.tar.gz
wf@fur:/var/www/html$ sudo tar xvfz /usr/local/src/mediawiki-1.33.2.tar.gz
sudo ln -s mediawiki-1.33.2 wiki

Configure Localsettings.php

set mysql root password

follow steps

and download LocalSettings.php

make phpinfo.php available

<?php
  phpinfo();

Install Xdebug

sudo apt-get install php-xdebug php-dev php-curl
sudo apt install php-pear
sudo pecl channel-update pecl.php.net
sudo pecl install xdebug

Create first project

New Project "loop" add loop.php in include_path/loop folder

<?php
for ($i = 1; $i <= 10; $i++) {
    echo $i;
}
  1. Try Run / Debug as PHP CLI Application
  2. You'll be asked to add PHP env
  3. Click "add" to add a New PHP Executable
  4. use /usr/bin/php as Executable path
  5. use system default php.ini
  6. Click "finish"
  7. Click "Apply and Close"
  8. Try Run/Debug as PHP CLI Application again
  9. Set breakpoints and debug

Eclipsedebug2020-02-08.png

Create MediaWiki Project

make sure your user is part of group www-data

/var/www/html$ sudo chown www-data.www-data mediawiki-1.33.2
/var/www/html$ sudo chmod g+w mediawiki-1.33.2/
/var/www/html$ sudo chown -R www-data.www-data wiki

Create Eclipse project with "open project from existing source" using /var/www/html/wiki as the source folder

Enable composer in Project's properties There should be only some 20 errors and 60 warnings. Mostly the errors are XMLProblems and ComposerHook ComposerPack issues which are hopefully not relevant.

Debugging

Set your breakpoints e.g. in the code of an extension. Then click index.php and right click "Run Debug as PHP Web Application". You'll be asked for the URL to debug Debugdialog2020-02-09.png

Add Extension to debug

e.g. S5SlideShow

{
	"require": {
		"wikimedia/at-ease": "*"
	}
}
wget https://getcomposer.org/composer.phar
sudo php composer.phar update

Debug Extension

XDebug

/etc/php/7.2/mods-available$ cat xdebug.ini 
zend_extension=xdebug.so
xdebug.remote_enable=On
sudo service apache2 restart

try Zend Debugger

Did not work ...

Download

drwxrwxr-x 3 wf   wf        4096 Feb 23  2017 ZendDebugger-linux-x86_64
-rw-rw-r-- 1 wf   wf     1169184 Feb  8 17:01 ZendDebugger-linux-x86_64.tar.gz

steps tried

see https://askubuntu.com/questions/1002252/installing-configuring-zend-debugger-for-eclipse-pdt

  1. copy dummy.php to webroot
cat 20-zend.ini 
zend_extension=/usr/local/src/ZendDebugger-linux-x86_64/php-7.0.x/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1,2.0.0.21
zend_debugger.expose_remotely=allowed_hosts
zend_debugger.tunnel_min_port=1025
zend_debugger.tunnel_max_port=65534