Month: July 2009

MQ+PHP – Linking IBM’s WebSphere MQ to PHP

During a recent project at work I had to get PHP linked with IBM’s WebSPhere MQ software we have running on another internal server. Our goal was to use our existing web service to take the requests from external vendors and push their XML data back into the queue inside our firewall. Thankfully there’s an extension in PECL that does just that.

Here’s the basic steps I took – hopefully it’ll be useful to someone else out there in the same spot I was. This all assumes you’re working on a web server that doesn’t have an MQ server installed already:

  • Get the extension: Head over to the PECL page for mqseries and download the latest version. Unpack it into a directory on your local server
  • Get the MQ client libs: You’ll need to go to IBM’s website to download the latest client/libraries for your install (you’ll need an IBM ID to get to the downloads):
    • Go to the IBM page for the MQ client listing
    • Look for the “WebSphere MQ Clients” link under the “Related products and technologies” section and click on it
    • Scroll down to the “Download Package” section and choose from one of the mirror locations
    • Select your package from the list (I went with “Linux for System x86” for our setup)
    • Click on the download link and fill out some required information (you didn’t think you were getting off that easy, did you?)
    • Agree to the terms and conditions and you’ll get a “Download Now” link
    • Drop the archive file (tar, tar.gz, etc) into your server and unpack into a temporary directory (mine had an issue unpacking into the local directory, not a subdirectory)
  • Install the package(s): Once you have the IBM software extracted, you should have a series of packages. You’ll need to install the “MQSeriesSDK” to get the right libraries in place to compile the PHP extension
  • Build the mqseries extension: Go into the mqseries directory and run “phpize”, “./configure” and “make” to create the .so file. The process should drop it into the default extensions directory.
  • If needed, move it: Be sure that the shared module for the extension is in the right directory for the PHP install to find it. (You can make a phpinfo() page if you’re not sure where that is.)
  • Update your php.ini: Add in a line to include the extension in your current setup. Remember, after any changes to the php.ini, you need to restart the web server.

Now for the fun part – if everything’s working and the extension shows up in your phpinfo() as active, give this script a shot and see if you can connect to your MQ server:

$mq_host_ip =’′;
$queue_name = ‘HOST.REMOTE.Q’;
$mq_server = ‘WBRK_QM_U49’;
$mqcno = array(
‘MQCD’ => array(
‘ChannelName’ => ‘CLIENT.CHANNEL’,
‘ConnectionName’ => $mq_host_ip,
‘TransportType’ => MQSERIES_MQXPT_TCP

// Connect to the MQ server
if ($comp_code !== MQSERIES_MQCC_OK) {
trigger_error(‘Cannot open connection to server: ‘.$mq_server,E_USER_ERROR);
echo ‘Connection good!’;

Obviously you’ll need to adjust the settings to fit your server, but at least this gives you a start.


Thinking Agile

Along with some of the fun new things I’ve been working on it regards to development and deployment, I’ve also been reading up on the agile development methods. I’m only getting started and I can already tell you – it’s not like anything you’re used to (well, unless you’ve already “gone agile”, of course).

Despite all of the hype right now around Scrum, I figured I’d get my feet wet with the agile concepts with Extreme Programming first. I’m assuming that most of the principles will be similar with varying implementations between the two. My “manual” of choice to get started with has been O’Reilly’s “The Art of Agile Programming” (James Shore, Shane Warden) and it’s been an eye opener.

See, I’ve come from a place where, I imagine, most developers out there are coming from and probably still will be in the future. You spend months gathering requirements, you estimate the times, you set the deadlines – all very structured and, depending on who you’re doing the work for, potentially wasteful. We’ve all experienced the frustration of changes to requirements set at the beginning of the project. Things tend to explode when someone changes “one small thing” and the entire development track is suddenly ripped into pieces and put at the complete mercy of what the customer wants.

In short, it sucks.

From what I’ve gathered so far, the whole concept behind agile programming is to prevent things like this. It makes it simpler to move around in the project and change things that might need changing. Work is done in sprints instead of one long development process and the client/business representative selects the things that will be headed into the next development session. Requirements are more fluid and testers don’t have to wait until everything’s done to find where things break.

I’m definitely still in the learning process, but so far, this agile process doesn’t seem half bad. I just wish it didn’t require such a large change in the processes of the surrounding company. I might be tempted to suggest it around my office…

Speaking in the Fall

With the announcement of the speakers for this year’s Zend/PHP Conference it seems I’ll be giving three talks this fall (in the span of two months):

First at CodeWorks 2009 (Dallas) I’ll be giving a talk on best practices, standards and tools to help with both in your PHP development:

  • “B,S,T…Easy as 1,2,3”

The other two will be at ZendCon (in San Jose). They’re on two different topics:

  • “Taming the Deployment Beast” – looking at some of the development and deployment practices that can make releasing your code simpler
  • “Right Where You Belong (The PHP Community)” – no matter what your skill level or area of focus, everyone has a place they can call their own in the PHP community. This talk highlights a few of them.

Hope to see you all there! Here’s more info on the two conferences: CodeWorks (Sept. 26th-27th in Dallas) and ZendCon (Oct. 19th-22nd in San Jose)