Posts Tagged ‘howto’

Howto: Xdebug installation and setup

Tuesday, October 3rd, 2006

To install Xdebug, it’s easy if you’ve installed PHP extensions before, follows the basic 4 step procedure. Also we’ll need to download it, I’ve been using the latest 2.0 beta with no problems, you can visit the Xdebug site to get more information and download it.

First we have to run phpize, this builds the configure script and other make/configure related files tailored to your install of PHP, you’ll need your PHP install’s bin folder in path, typically this is for system installed PHP or custom installs in /usr/local. If you installed PHP via something like apt in debian or ubuntu, you’ll need a particular package, this should be ‘php5-dev’ which includes phpize and necessary files to build PHP extensions. Then we can run configure, make, then make install to install it. The basic installation commands:

$ cd xdebug-2.0.0beta6

$ phpize

$ ./configure

$ make

$ sudo make install

Now that we installed it, Xdebug requires some minimal php.ini setup, particularly a special way of loading the extension unlike normal ones. I basically want the debugger available when I need it, and for Xdebug to be using it’s stack traces for any notices/errors, and profiling to be only on when I want it. Below is what I have, for debugging support (which requires something like Komodo or Eclipse with Xdebug support) you’ll need to enter the address of the machine that will have a debugger, along with the port, and the username you’re on on that machine. So this setup, my laptop will do any debugging, and I’m always ‘jerome’ on any machine, which is what the debugger clients usually use to identify the ide/client. For profiling you’ll need to have a directory writable by the web server where the cachegrind formatted profiler dumps go which is the last option I have.

zend_extension= /usr/lib/php5/20051025/xdebug.so ;full path to xdebug extension, installed in your extensions folder

xdebug.remote_enable=1

xdebug.remote_handler=dbgp

xdebug.remote_mode=req

xdebug.remote_host=192.168.1.40

xdebug.remote_port=9001

xdebug.idekey=jerome

xdebug.profiler_enable = 0

xdebug.profiler_enable_trigger = 1

xdebug.profiler_output_dir = /storage/sites/profiler_files

For other options, you can consult www.xdebug.org for documentation on xdebug and it’s configuration, available functions, and more.

Now to use profiling, all you have to do is restart web server if you haven’t already after saving php.ini changes, and then any script you want profiled, just include XDEBUG_PROFILE=1 in GET or POST and this will cause profiling to be run and a cachegrind.out.##### type file to be generated in the path specified in php.ini. It’s best to rename the file to something usable after the script is done so you know what it is, and if you do the same script, it might try to write to that same file. These files are then best viewed in a program that knows cachegrind format, like KCacheGrind as seen in my previous post.

Technorati Tags: , , , ,

Howto: Subversion externals basics

Friday, June 23rd, 2006

Here’s a quick howto on using subversion externals to load other subversion repositories into various directories of your project. We use this at “work”:http://www.rainstormconsulting.com to load in shared classes so that they’re versioned in one location. We could possibly use something like “PEAR”:http://pear.php.net to provide some of those but this method is nicer I think, and all in one spot. To setup an external for a directory in your repository, I typically start at the root project directory, say MyProject, and set it there. Externals are a “subversion property”:http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html which holds some text as to what to what paths pull from what URLs. The easiest method to edit externals I think is to use the _svn propedit_ command. This will require you to have an editor set for EDITOR or SVN_EDITOR environment variable (and this applies to unix/osx type systems) before you can successfully use svn propedit. The actual property name is _svn:externals_ and we can use the commands svn propset or propedit etc. to work with it, easiest is propedit so that’s what I’ll demonstrate.

$ cd MyProject
$ export SVN_EDITOR=vim
$ svn propedit svn:externals .

Now you can make changes to the externals of the current directory specified by ‘.’, you can specify a path-url combination per line, then save and exit your editor to finish the change. The path part comes first, and is relative to where your setting the external. Example of the format:

classes/MyUtilities http://example.com/svn/MyUtilities/classes

Once your done adding externals, you can run svn update to actually pull down the external, you’ll need to commit to actually push the external property change to the server so anybody else working on the project gets it too.

$ svn update
$ svn commit -m ‘Added external for classes/MyUtilities’

There, any changes made to the other repository or path will come down when you do svn update. You can also commit changes within that external’s directory by just entering that and doing normal subversion commands.

Technorati Tags: , , , ,

Howto: Basic Subversion setup and usage

Tuesday, May 30th, 2006

So you want to setup a Subversion(SVN) repository? Well I know the basics and hopefully I can give a nice to-the-point tutorial on how to get up and running with tracking your source code through SVN. Subversion can easily be used as a personal change tracking system on your local computer, or be used with a team to track changes from everybody and facilititate conflict resolution with similar changes. I also see it as a super undo in case you really manage to screw stuff up. Although proper version tracking requires you getting in the habbit of reguarly commiting changes. Read more for the tutorial (Decided to stop doing full posts on front page, getting LONG)

Update: If your using OS X, check out SvnX for a GUI for manging working copies, and doing some repository actions too.

Technorati Tags: , , , ,

(more…)

Install PHP with Extensions Howto

Monday, March 13th, 2006

I decided to write up a post about how to compile & install PHP with support for using extensions to provide all the functionality instead of building everything in. Compiling in everything seems to be pretty common, with the windows PHP install using extensions to enable anything like mysql, pdo, curl, and more.

These instructions will apply to linux or OS X, where OS X has one minor problem which is with “PDO”:http://www.php.net/pdo, therefore if your doing this on OS X, compile PHP with PDO + PDO drivers you need instead of trying to install them as separate extensions.

If you have any comments, thoughts, or questions, feel free to comment or email me(You gotta look for my email :-P ).

*Update:* Soooo apparently majority of the extensions fail to even try to compile on OS X, the makefile isn’t generated properly so nothing compiles so nothing can be installed. I had to build in curl, pdo, and xsl since they failed to build separately. These all worked in debian linux.

(more…)