Archive for the 'Software' category

Debugging two PHP projects in Netbeans at the same time

published on August 19, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’m currently working on some Symfony2 bundles and I have one Netbeans project for the main Symfony2 app and one project for the bundle. The bundle files are completely separated from the app and they are just linked (ln -s) together. It works great, except for the case when I need to debug some part of the bundle’s code with Netbeans + xdebug. The debugger starts for the “main” project, which is the Symfony2 app, but setting breakpoints with Netbeans (y’know, by clicking the line number) for the bundle doesn’t really work, as those are in the other project and not in the debugged one, rendering the whole debugging useless.

The solution is pretty easy actually: instead of setting breakpoints with Netbeans, use xdebug_break() where you want the break to happen and it will happily be caught by the IDE. After the break happened use the “Step into” (F7) functionality to see what’s going on.

Changing Jenkins' home directory on Ubuntu

published on August 04, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’ve started to play around with Jenkins yesterday and I kinda don’t like that it’s default home directory is /var/lib/jenkins so I changed it to /home/jenkins, so I’m throwing the steps needed out here for future reference.

First, stop jenkins:

robert@odin:~$ sudo /etc/init.d/jenkins stop

Create the new home directory and move existing stuff from the old home to the new one:

robert@odin:~$ sudo usermod -m -d /home/jenkins jenkins

Now, I didn’t manage to set the ENV JENKINS_HOME to the new home, it was always using the old one, so I edited the init.d script:

robert@odin:~$ sudo vi /etc/init.d/jenkins

and in the “DAEMON_ARGS=…” line change JENKINS_HOME env to –env=JENKINS_HOME=/home/jenkins. In the end the whole line reads something like:

DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=/home/jenkins --output=$JENKINS_LOG --pidfile=$PIDFILE"

Update on September 20th: Vranac blogged about how to change the JENKINS_HOME properly

Start jenkins

robert@odin:~$ sudo /etc/init.d/jenkins start

and go to http://server:port/configure and verify that jenkins works as before and is using the new home.

Happy hackin’!

Tags: hack, jenkins, ubuntu.
Categories: Development, Software.

Debugging Zend Framework unit tests with Xdebug and NetBeans

published on July 24, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I’ve spent this weekend hacking on some unit tests for Zend\Dojo and I ran into an issue where I need Xdebug to, well, debug. Note, that this is not for debugging a Zend Framework application, but for debugging Zend Framework itself. I am using Netbeans + Xdebug to debug regular code, but debugging unit tests was something completely new for me. Turns out, it’s not entirely different from “regular” debugging.

Greatest help to figure out this was Raphael Dohms’ blog post “Debugging PHPUnit tests in Netbeans with Xdebug”. Almost worked out fine, but Netbeans complained about a missing index file and the autoload of files was… not really working. After a bit of poking around, the solution was to go to File -> Project Properties -> Run Configuration and set the “Index File” to /path/to/zend_framework_2/tests/_autoload.php - no more missing index file and the autoload works too!

Starting the debug session stays the same as explained in Raphael’s post: click “Debug project” (CTRL+F5), go to the terminal and just type something like:

robert@odin:~/www/zf2/tests$ /path/to/phpunit-debug Zend/Dojo/DojoTest.php

Netbeans will pick up the connection and debugging can start!

Happy hackin’!

pecl install apc fails on Ubuntu

published on April 10, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I was just installing APC on an Ubuntu server (what else to do on a Sunday morning?) with the standard set of commands:

sudo apt-get install php-pear php5-dev
sudo pecl install apc

but the pecl install apc died with a bunch of “/tmp/pear/temp/APC/apc.c:430: error: “apc_regex” has no member named “preg”” and similar messages. Luckily, I can use google which led me to this serverfault answer: I was missing the “libpcre3-dev” package. After doing a quick sudo apt-get install libcpre3-dev APC got installed correctly.

Tags: apc, libpcre3, pecl.
Categories: Development, Software.

Installing FreeBSD 8.2

published on March 27, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

As I’m currently in the progress of installing FreeBSD on my first machine (out of 4), writing the process down for future reference sounds like a pretty good idea :)

I’ve installed it from the CD image. The installation process was straightforward, altho either the boot loader or freebsd was getting confused in the first few attempts because I was installing it on the slave HDD. After installing it on the master, everything went fine.

On this machine I’m using a LevelOne WNC0305 USB wireless card which uses realtek’s dreaded RTL8187 chipset. After a bit of a googling, I ended up on the freebsd 8.2 hardware notes page, which in the wireless section lists all the available wireless drivers. From there I figured I need to use the urtw driver, that is to add:

if_urtw_load="YES"

to the /boot/loader.conf file. After rebooting the machine, it recognised my wireless card as urtw0. Hooray! Now to connect to the wireless router and onto the world.

For that, this message about (not) getting the ifconfig scan results helped me out, this bit to be precise:

# ifconfig wlan0 create wlandev urtw0
# ifconfig wlan0 up list scan

and it listed my router correctly. To make it stay that way after rebooting, I’ve added this to the /etc/rc.conf file (I might note that it was empty before this):

wlans_urtw0="wlan0"

At this time I figured I just could ssh to one of the servers in the office (we run freebsds there) and “steal” rest of the configuration, so I ended up with a /etc/rc.conf file something like this:

hostname="freebsd_box"
wlans_urtw0="wlan0"
ifconfig_wlan0="inet 192.168.0.100 netmask 255.255.255.0"
defaultrouter="192.168.0.1"

Reboot once again and I can ping anything via IP, but not via hostnames. Again, this (ooold) message about DNS settings in freebsd showed me the right direction - /etc/resolv.conf:

nameserver ip.of.name.server1
nameserver ip.of.name.server2

Reboot and everything is working fine! Victory!

Next step was (is) to fetch/update the ports database:

# csup -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile

From here I believe it’s all about installing software from the ports which should be all fine.

Happy hackin’!

Robert Basic

Robert Basic

Software engineer, consultant, open source contributor.

Let's work together!

If you require outsourcing or consulting help on your projects, I'm available!

Robert Basic © 2008 — 2019
Get the feed