Eclipse and XDebug NIGHTMARE

Welcome to my nightmare.

To see listeners:

 # netstat -anp | grep LISTEN | less
 # nmap localhost

To use IPv4 instead of IPv6 in Eclipse, edit:

/home/jj5/.eclipse/org.eclipse.platform_3.8_155965261/configuration/config.ini

And add:

 # https://lists.debian.org/debian-java/2010/03/msg00073.html
 java.net.preferIPv4Stack=true

More to come…

PDO Persistent Connection in PHP left broken if connected to dropped database

So you use PDO and specify PDO::ATTR_PERSISTENT => true. Then you drop your database. Then you open a new persistent connection and bang! Not working. The trick is to not use persistent connections to databases that may be dropped. And probably an ‘apache2ctl graceful’ after you drop a database being used by Apache…

Debugging PHPUnit tests in Eclipse PDT with XDebug on Debian GNU/Linux

Wow, this was complicated!

Make sure PHP, Xdebug, etc. are installed:

 # apt-get install php php5-xdebug php5-curl php5-mysql php5-gd

Install Eclipse:

 # apt-get install eclipse

To install PHP Developer Tools in Eclipse: Open Eclipse, click Help -> Install New Software…

Work with: http://download.eclipse.org/tools/pdt/updates/release

Select PHP Development Tools / PHP Development Tools (PDT) and install.

Create a new PHP project in Eclipse.

Download PHPUnit into your project folder, e.g.:

 $ cd ~/workspace/new-project
 $ wget https://phar.phpunit.de/phpunit.phar
 $ chmod +x phpunit.phar
 $ cp phpunit.phar /usr/local/bin/phpunit

In your Eclipse PHP project right-click on your project and select “Include Path” -> “Configure Include Path”.

Click “Libraries” -> “Add External PHARs” then add “phpunit.phar” (in your project’s workspace).

In Eclipse click “Run” -> “Debug Configurations”. Click “PHP CLI Application” and then “New”. Enter the PHP Script name as “PHPUnit” with Project default PHP: PHP CLI (Xdebug 5.4.4 CLI). Set the PHP file as “/project-name/phpunit.phar”.

Edit your php.ini file, e.g.:

 # vim /etc/php5/cli/php.ini

And make sure to specify an xdebug configuration (append to end of file is OK):

[xdebug]
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable=On
;xdebug.remote_host="localhost"
xdebug.remote_host=localhost
;xdebug.remote_port=9999
;xdebug.remote_port=9000
xdebug.remote_port=9999
xdebug.remote_handler="dbgp"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/var/tmp"

xdebug.default_enable = on

xdebug.remote_autostart=on
xdebug.remote_mode = "req"
xdebug.remote_connect_back = on
xdebug.remove_log = /tmp/xdebug.log

Make sure you have a phpunit.xml file next to phpunit.phar in your workspace, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
  backupStaticAttributes="false"
  syntaxCheck="false">
  <testsuites>
    <testsuite name="Tests">
       <directory suffix="Test.php">test</directory>
    </testsuite>
  </testsuites>
</phpunit>

Make sure there is one test in your test directory, e.g. /project-name/test/MyTest.php

<?php
class MyTest extends PHPUnit_Framework_TestCase {

  public function setUp() {
    //require_once( __DIR__ . '/../src/example.php' );
  }

  public function testExample() {
    $this->assertSame( '1', '1' );
  }
}

Double-click in the sidebar next to $this->assertSame to put a breakpoint there.

Then in Eclipse on the toolbar at the top is a little ‘bug’ icon, click ‘down’ next to that and debug ‘PHPUnit’.

Your unit tests should run in PHPUnit and break into the PHP debugger in Eclipse.

Did that work for you? Let me know!

Language Codes

Found a List of Language Codes:

af Afrikaans sq Albanian
ar-sa Arabic (Saudi Arabia) ar-iq Arabic (Iraq)
ar-eg Arabic (Egypt) ar-ly Arabic (Libya)
ar-dz Arabic (Algeria) ar-ma Arabic (Morocco)
ar-tn Arabic (Tunisia) ar-om Arabic (Oman)
ar-ye Arabic (Yemen) ar-sy Arabic (Syria)
ar-jo Arabic (Jordan) ar-lb Arabic (Lebanon)
ar-kw Arabic (Kuwait) ar-ae Arabic (U.A.E.)
ar-bh Arabic (Bahrain) ar-qa Arabic (Qatar)
eu Basque (Basque) bg Bulgarian
be Belarusian ca Catalan
zh-tw Chinese (Taiwan) zh-cn Chinese (PRC)
zh-hk Chinese (Hong Kong SAR) zh-sg Chinese (Singapore)
hr Croatian cs Czech
da Danish nl Dutch (Standard)
nl-be Dutch (Belgium) en English
en-us English (United States) en-gb English (United Kingdom)
en-au English (Australia) en-ca English (Canada)
en-nz English (New Zealand) en-ie English (Ireland)
en-za English (South Africa) en-jm English (Jamaica)
en English (Caribbean) en-bz English (Belize)
en-tt English (Trinidad) et Estonian
fo Faeroese fa Farsi
fi Finnish fr French (Standard)
fr-be French (Belgium) fr-ca French (Canada)
fr-ch French (Switzerland) fr-lu French (Luxembourg)
gd Gaelic (Scotland) ga Irish
de German (Standard) de-ch German (Switzerland)
de-at German (Austria) de-lu German (Luxembourg)
de-li German (Liechtenstein) el Greek
he Hebrew hi Hindi
hu Hungarian is Icelandic
id Indonesian it Italian (Standard)
it-ch Italian (Switzerland) ja Japanese
ko Korean ko Korean (Johab)
lv Latvian lt Lithuanian
mk Macedonian (FYROM) ms Malaysian
mt Maltese no Norwegian (Bokmal)
no Norwegian (Nynorsk) pl Polish
pt-br Portuguese (Brazil) pt Portuguese (Portugal)
rm Rhaeto-Romanic ro Romanian
ro-mo Romanian (Republic of Moldova) ru Russian
ru-mo Russian (Republic of Moldova) sz Sami (Lappish)
sr Serbian (Cyrillic) sr Serbian (Latin)
sk Slovak sl Slovenian
sb Sorbian es Spanish (Spain)
es-mx Spanish (Mexico) es-gt Spanish (Guatemala)
es-cr Spanish (Costa Rica) es-pa Spanish (Panama)
es-do Spanish (Dominican Republic) es-ve Spanish (Venezuela)
es-co Spanish (Colombia) es-pe Spanish (Peru)
es-ar Spanish (Argentina) es-ec Spanish (Ecuador)
es-cl Spanish (Chile) es-uy Spanish (Uruguay)
es-py Spanish (Paraguay) es-bo Spanish (Bolivia)
es-sv Spanish (El Salvador) es-hn Spanish (Honduras)
es-ni Spanish (Nicaragua) es-pr Spanish (Puerto Rico)
sx Sutu sv Swedish
sv-fi Swedish (Finland) th Thai
ts Tsonga tn Tswana
tr Turkish uk Ukrainian
ur Urdu ve Venda
vi Vietnamese xh Xhosa
ji Yiddish zu Zulu

Failed to verify krb5 credentials: Server not found in Kerberos database

I was getting “Failed to verify krb5 credentials: Server not found in Kerberos database” errors when trying to use Kerberos authentication in Apache2. The problem was in my /etc/hosts file. I needed to change this:

10.183.97.44    charity.progclub.org charity
67.207.128.184  charity-public

To this:

10.183.97.44    charity.progclub.org charity
67.207.128.184  charity.progclub.org charity-public

Disabling sound in Debian KDE

I’m having a problem whereby my KDE session is “locking up” periodically for 5 or 10 minutes at a time. I checked /var/log/syslog and dmesg and it *seems* as though the high-priority audio threads are staving other threads, so I figure I’ll try to disable sound and see if my system continues to lock up. To disable sound I used:

root@mercy:/home/jj5# alsa force-unload
Unloading ALSA sound driver modules: snd-ens1371 snd-ac97-codec snd-seq-midi snd-seq-midi-event snd-rawmidi snd-pcm snd-page-alloc snd-seq snd-seq-device snd-timer (failed: modules still loaded: snd-ens1371 snd-ac97-codec snd-rawmidi snd-pcm snd-page-alloc snd-seq-device snd-timer).