Difference between revisions of "PHP Mediawiki Eclipse debugging"
(38 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
= Environment = | = Environment = | ||
+ | == 2020-10-11 == | ||
+ | * LAMP Intranet MediaWiki 1.35 with no security needs in a VMWare environment | ||
+ | <source lang='bash' highlight='1,7,10,12'> | ||
+ | lsb_release -a | ||
+ | No LSB modules are available. | ||
+ | Distributor ID: Ubuntu | ||
+ | Description: Ubuntu 20.04.1 LTS | ||
+ | Release: 20.04 | ||
+ | Codename: focal | ||
+ | apachectl -V | ||
+ | Server version: Apache/2.4.41 (Ubuntu) | ||
+ | Server built: 2020-08-12T19:46:17 | ||
+ | mysql --version | ||
+ | mysql Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 | ||
+ | php --version | ||
+ | PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) | ||
+ | Copyright (c) The PHP Group | ||
+ | Zend Engine v3.4.0, Copyright (c) Zend Technologies | ||
+ | with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies | ||
+ | with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans | ||
+ | </source> | ||
+ | |||
+ | == 2020-02-09 == | ||
* LAMP Intranet MediaWiki 1.33 with no security needs in a VMWare environment | * LAMP Intranet MediaWiki 1.33 with no security needs in a VMWare environment | ||
− | <source lang='bash'> | + | <source lang='bash' highlight='1,7,10,12'> |
lsb_release -a | lsb_release -a | ||
No LSB modules are available. | No LSB modules are available. | ||
Line 23: | Line 46: | ||
= Install eclipse php = | = Install eclipse php = | ||
+ | == 2020-02 == | ||
<source lang='bash'> | <source lang='bash'> | ||
cd /usr/local/src | cd /usr/local/src | ||
Line 29: | Line 53: | ||
sudo tar xvfz eclipse-php-2019-12-R-linux-gtk-x86_64.tar.gz | sudo tar xvfz eclipse-php-2019-12-R-linux-gtk-x86_64.tar.gz | ||
</source> | </source> | ||
+ | == 2020-10 == | ||
+ | Use Installer from e.g. https://ftp.snt.utwente.nl/pub/software/eclipse/oomph/epp/2020-09/R/eclipse-inst-jre-linux64.tar.gz and select Eclipse IDE for PHP Developers | ||
+ | <source lang='bash'> | ||
+ | cd /usr/local/src | ||
+ | wget https://ftp.snt.utwente.nl/pub/software/eclipse/oomph/epp/2020-09/R/eclipse-inst-jre-linux64.tar.gz | ||
+ | tar xvfz eclipse-inst-jre-linux64.tar.gz | ||
+ | cd eclipse-installer | ||
+ | ./eclipse-inst | ||
+ | # select Eclipse IDE for PHP Developers | ||
+ | # Installation Folder: /usr/local/src/eclipse | ||
+ | </source> | ||
+ | |||
== Desktop icon == | == Desktop icon == | ||
<source lang='bash'> | <source lang='bash'> | ||
Line 46: | Line 82: | ||
<source lang='bash'> | <source lang='bash'> | ||
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring | sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring | ||
+ | </source> | ||
+ | == Mediawiki 1.33.2 == | ||
+ | <source lang='bash'> | ||
/usr/local/src$ sudo wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.2.tar.gz | /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 | 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 | sudo ln -s mediawiki-1.33.2 wiki | ||
</source> | </source> | ||
+ | == Mediawiki 1.35 == | ||
+ | <source lang='bash'> | ||
+ | /usr/local/src$ sudo wget wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.0.tar.gz | ||
+ | wf@fur:/var/www/html$ sudo tar xvfz /usr/local/src/mediawiki-1.35.0.tar.gz | ||
+ | rm wiki | ||
+ | wf@fur:/var/www/html$ ln -s mediawiki-1.35.0/ wiki | ||
+ | </source> | ||
+ | |||
== Configure Localsettings.php == | == Configure Localsettings.php == | ||
=== set mysql root password === | === set mysql root password === | ||
+ | ==== Ubuntu 18.04 / mysql ==== | ||
* https://www.digitalocean.com/community/tutorials/so-installieren-sie-mysql-auf-ubuntu-18-04-de | * https://www.digitalocean.com/community/tutorials/so-installieren-sie-mysql-auf-ubuntu-18-04-de | ||
+ | ==== Ubuntu 20.04 /mardiab ==== | ||
+ | <source lang='bash'> | ||
+ | mysql_secure_installation | ||
+ | </source> | ||
=== follow steps === | === follow steps === | ||
and download LocalSettings.php | and download LocalSettings.php | ||
Line 61: | Line 113: | ||
phpinfo(); | phpinfo(); | ||
</source> | </source> | ||
+ | |||
= Install Xdebug = | = Install Xdebug = | ||
<source lang='bash'> | <source lang='bash'> | ||
− | sudo apt-get install php-xdebug php-dev | + | sudo apt-get install php-xdebug php-dev php-curl |
+ | </source> | ||
+ | == 2020-02 == | ||
+ | <source lang='bash'> | ||
sudo apt install php-pear | sudo apt install php-pear | ||
sudo pecl channel-update pecl.php.net | sudo pecl channel-update pecl.php.net | ||
Line 88: | Line 144: | ||
#Set breakpoints and debug | #Set breakpoints and debug | ||
[[File:eclipsedebug2020-02-08.png|400px]] | [[File:eclipsedebug2020-02-08.png|400px]] | ||
+ | |||
+ | == 2020-10 == | ||
+ | Also need to configure debugger as asked for by Eclipse - use xdebug. | ||
= Create MediaWiki Project = | = Create MediaWiki Project = | ||
Line 97: | Line 156: | ||
</source> | </source> | ||
Create Eclipse project with "open project from existing source" using /var/www/html/wiki as the source folder | 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. | ||
+ | == DLTK Indexing == | ||
+ | When first loading the project the DLTK indexing will take place and might take a while ... | ||
+ | * https://stackoverflow.com/questions/13345011/dltk-indexing-in-progress | ||
+ | |||
+ | == Debugging == | ||
+ | === Setting Eclipse PHP Debug Preferences === | ||
+ | Personally I think break on first line isn't helpful because it triggers to often. | ||
+ | [[File:PHPDebugPreferences2020-10-12.png|600px]] | ||
+ | === Setting breakpoints === | ||
+ | Set your breakpoints e.g. in the code e.g. 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|1000px]] | ||
+ | |||
+ | After clicking "debug" the code will hopefully halt at one of your breakpoints and you can inspect what is going on. | ||
+ | |||
= Add Extension to debug= | = Add Extension to debug= | ||
+ | e.g. {{Link|target=S5SlideShow}} | ||
<source lang='json'> | <source lang='json'> | ||
{ | { | ||
Line 109: | Line 187: | ||
sudo php composer.phar update | sudo php composer.phar update | ||
</source> | </source> | ||
+ | = Debug Extension = | ||
+ | * https://www.eclipse.org/pdt/help/html/debugging_a_php_web_page.htm | ||
+ | [[File:MediaWikiDebugScreenShot2020-10-12.png|800px]] | ||
+ | == XDebug == | ||
+ | === 2020-02 === | ||
+ | <source lang='bash' highlight='1,4'> | ||
+ | /etc/php/7.2/mods-available$ cat xdebug.ini | ||
+ | zend_extension=xdebug.so | ||
+ | xdebug.remote_enable=On | ||
+ | sudo service apache2 restart | ||
+ | </source> | ||
+ | === 2020-10 === | ||
+ | <source lang='bash' highlight='1,6'> | ||
+ | /etc/php/7.4/apache2/conf.d# cat 20-xdebug.ini | ||
+ | zend_extension=xdebug.so | ||
+ | xdebug.remote_enable=On | ||
+ | # only use when really debugging will slow down your apache quite a bit | ||
+ | # https://stackoverflow.com/a/19273025/1497139 | ||
+ | #xdebug.remote_autostart=1 | ||
+ | </source> | ||
+ | |||
+ | == try Zend Debugger == | ||
+ | Did not work ... | ||
+ | === Download === | ||
+ | <source lang='bash'> | ||
+ | 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 | ||
+ | </source> | ||
+ | == steps tried == | ||
+ | see https://askubuntu.com/questions/1002252/installing-configuring-zend-debugger-for-eclipse-pdt | ||
+ | # copy dummy.php to webroot | ||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> |
Latest revision as of 10:28, 13 November 2020
Trying to get https://www.semantic-mediawiki.org/wiki/User:WolfgangFahl/Workdocumentation_2015-12-27 working again
Environment
2020-10-11
- LAMP Intranet MediaWiki 1.35 with no security needs in a VMWare environment
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
apachectl -V
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2020-08-12T19:46:17
mysql --version
mysql Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
php --version
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
2020-02-09
- 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
2020-02
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
2020-10
Use Installer from e.g. https://ftp.snt.utwente.nl/pub/software/eclipse/oomph/epp/2020-09/R/eclipse-inst-jre-linux64.tar.gz and select Eclipse IDE for PHP Developers
cd /usr/local/src
wget https://ftp.snt.utwente.nl/pub/software/eclipse/oomph/epp/2020-09/R/eclipse-inst-jre-linux64.tar.gz
tar xvfz eclipse-inst-jre-linux64.tar.gz
cd eclipse-installer
./eclipse-inst
# select Eclipse IDE for PHP Developers
# Installation Folder: /usr/local/src/eclipse
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
Mediawiki 1.33.2
/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
Mediawiki 1.35
/usr/local/src$ sudo wget wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.0.tar.gz
wf@fur:/var/www/html$ sudo tar xvfz /usr/local/src/mediawiki-1.35.0.tar.gz
rm wiki
wf@fur:/var/www/html$ ln -s mediawiki-1.35.0/ wiki
Configure Localsettings.php
set mysql root password
Ubuntu 18.04 / mysql
Ubuntu 20.04 /mardiab
mysql_secure_installation
follow steps
and download LocalSettings.php
make phpinfo.php available
<?php
phpinfo();
Install Xdebug
sudo apt-get install php-xdebug php-dev php-curl
2020-02
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;
}
- Try Run / Debug as PHP CLI Application
- You'll be asked to add PHP env
- Click "add" to add a New PHP Executable
- use /usr/bin/php as Executable path
- use system default php.ini
- Click "finish"
- Click "Apply and Close"
- Try Run/Debug as PHP CLI Application again
- Set breakpoints and debug
2020-10
Also need to configure debugger as asked for by Eclipse - use xdebug.
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.
DLTK Indexing
When first loading the project the DLTK indexing will take place and might take a while ...
Debugging
Setting Eclipse PHP Debug Preferences
Personally I think break on first line isn't helpful because it triggers to often.
Setting breakpoints
Set your breakpoints e.g. in the code e.g. 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
After clicking "debug" the code will hopefully halt at one of your breakpoints and you can inspect what is going on.
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
2020-02
/etc/php/7.2/mods-available$ cat xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=On
sudo service apache2 restart
2020-10
/etc/php/7.4/apache2/conf.d# cat 20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=On
# only use when really debugging will slow down your apache quite a bit
# https://stackoverflow.com/a/19273025/1497139
#xdebug.remote_autostart=1
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
- 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