Weblog

Some Thoughts on PHP's DateTime, Object Mutability and an Alternative Implementation

I'm beginning think that while the introduction of PHP's newish DateTime object is very welcome, its implementation is one of the big missed opportunities in the language. This is because the decision was taken to make it mutable. In essence, DateTime has been implemented as an Entity rather than a Value Object.

Continue reading Some Thoughts on PHP's DateTime, Object Mutability and an Alternative Implementation »

Posted on Thursday, the 22nd of September, 2011 | permalink | comments (3)

MongoDB Support for Tera-WURFL

This is just a quick heads up to point out that Tera-WURFL now has support for using MongoDB as its data store. This is particularly exciting for me, since I contributed the original code. I've been benefiting from Tera-WURFL for years now, so it's pleasing that our ongoing migration to MongoDB at work provided an opportunity to give something back.

Continue reading MongoDB Support for Tera-WURFL »

Posted on Thursday, the 2nd of September, 2010 | permalink | comments (2)

Successful Microsoft SQL Server Support for PHP on Linux

I recently had a requirement to enable a PHP application on Linux servers to connect to a remote Microsoft SQL Server database. Despite initial concerns that this was impossible or at least very difficult, compounded by numerous confused forum/blog posts suggesting it to be so, it turns out to be eminently achievable.

Unfortunately, there seems to be a lot of misinformation out there, so at the risk of adding to it, here's my writeup of getting PHP on Linux to talk to an MS SQL Server database, using both the mssql_* functions and the Zend_Db component of Zend Framework.

Continue reading Successful Microsoft SQL Server Support for PHP on Linux »

Posted on Thursday, the 13th of May, 2010 | permalink | comments (19)

Making Phone Calls and Sending SMS with HTML

Okay, so you can't really make phone calls and send SMS messages using only HTML; that would be silly. However, if you are developing web sites and web applications for mobile handsets, you can take advantage of some features in XHTML Mobile Profile which make it easy for a user to call a number without typing that number in. You can also use the same mechanism to trigger - on the user's handset - an SMS or MMS dialog with the intended recipient's number and the message content prepopulated.

That this can all be done by creating a specially-formatted HTML link on a web page is one of the most convenient, if occasionally misunderstood features of XHTML-MP. This post will tell you everything you need to know in order to take advantage of this feature.

Continue reading Making Phone Calls and Sending SMS with HTML »

Posted on Tuesday, the 19th of January, 2010 | permalink | comments (11)

HTTP in PHP, Part 1: The Request

When I wrote about HTTP for php|architect magazine, one of the topics that I ended up having to skim over for wordcount reasons was that of how to work with HTTP from within PHP.

So here's a quick overview of how to make and manipulate HTTP requests using PHP. I'll hopefully follow this up in due course with a counterpart post dealing with HTTP responses.

Continue reading HTTP in PHP, Part 1: The Request »

Posted on Wednesday, the 13th of January, 2010 | permalink | comments (1)

The Year Ahead in PHP

It's that time of year when thoughts, and indeed blog posts, inevitably turn to pondering the twelve months that have gone before. For my part, I thought it might be nicer to have a look forward into 2010 and think about some of the challenges and developments I might expect to come up against in my PHP work over the course of the year.

Continue reading The Year Ahead in PHP »

Posted on Monday, the 4th of January, 2010 | permalink | comments (1)

"HTTP For Developers" Published

The cover of php|architect's October 09 issue

If it's November already, that must mean that the October issue of php|architect magazine is out today, and with it comes the publication of another article by yours truly.

It's called "HTTP For Developers", which I hope should be fairly self-explanatory. I wanted to write about HTTP, because while it's really very important indeed, it tends not to be particularly well understood by developers.

So the article is kind of a whirlwind tour of how HTTP, and by extension the web itself, works, with what I hope is a particular focus on how this is relevant to developers. Hence the title.

There's plenty of other good stuff in this issue too, of course, including a couple of articles on image manipulation using PHP, and something I was particularly interested in: Brian DeShong's experiences using the original WURFL API for PHP to tailor content to mobile handsets.

Continue reading "HTTP For Developers" Published »

Posted on Monday, the 2nd of November, 2009 | permalink | comments (1)

How Do You Zend_View? I'll Show You Mine...

An interesting design decision made by the Zend Framework team was, well, not to make too many decisions about how the View portion of a Zend Framework MVC application should be implemented. You can use plain PHP to generate markup, use a templating library such as Smarty or Savant, or go your own way entirely. At work we've used both Wall4PHP, and subsequently a custom component-based solution, for example.

The flexibility is great then, but with freedom comes responsibility. Perhaps coincidentally, view scripts tend to be the part of a ZF app that attract the most cruft, the most untestable code, and the most mingling of concerns (though controllers certainly give them a run for their money).

Since someone recently asked, I'll show how I've implemented views on pointbeing.net. I don't claim that the approach is awesome, or even suitable for every case, but it seems to work for me. In return I'd very much like to hear or see how others implement their Zend_Views.

Continue reading How Do You Zend_View? I'll Show You Mine... »

Posted on Sunday, the 25th of October, 2009 | permalink | comments (2)

Lightweight Continuous Integration for PHP

This post describes a simple, lightweight strategy for implementing Continuous Integration on PHP-based software projects. This approach happens to use Subversion for version control, PHPUnit for unit testing, and Phing to automate the processes involved, but hopefully the principles are generally applicable.

The post won't strive to be exhaustive or encyclopaedic, rather it will present a simple proof-of-concept and a brief overview of the tools that are available to PHP developers. But first some background...

Continue reading Lightweight Continuous Integration for PHP »

Posted on Thursday, the 20th of August, 2009 | permalink | comments (5)

Zend_Session Overrides php.ini Settings

This post concerns some curious behaviour in Zend_Session. We spent about a day of developer time tracking this down, and I'm still a bit puzzled about it. It doesn't appear anywhere obvious in the documentation, and I haven't found a great deal on the web about it, so maybe this will save somebody some time, if nothing else.

Continue reading Zend_Session Overrides php.ini Settings »

Posted on Monday, the 13th of July, 2009 | permalink | comments (2)

A First Look at the New WURFL API for PHP

About a month ago, the New WURFL API for PHP was officially released. While the code had been available in one form or another for some time, the official release coincided nicely with the early stages of a new project at work, so it seemed like an appropriate time to have a look at the API and see if it was something we wanted to use.

By way of a refresher, WURFL is a "Device Description Repository" - a huge open-source XML-based database of information regarding mobile handsets and their capabilities. I've discussed WURFL in the past, for example here. Prior to this release, the only practical method of querying WURFL in real time from PHP was via a library named Tera-WURFL, which I blogged about here. In fact, both WURFL and Tera-WURFL were covered in an article I wrote for php|architect magazine last year.

We've generally been very happy with Tera-WURFL, but it's always worth considering one's options, so what follows is an overview of my experiences with, and first impressions of the New WURFL API.

Continue reading A First Look at the New WURFL API for PHP »

Posted on Monday, the 20th of April, 2009 | permalink | comments (5)

Unit Testing Code which Consumes SOAP Services

One of the trickiest aspects of unit testing or Test Driving an application's code is testing those parts of the system which depend on an external system, such as a database or a SOAP service.

In this post I'll outline an approach to testing a class which happens to communicate with a third-party SOAP service using PHP's built-in SoapClient class. Hopefully, the principles involved will be applicable to the more general case of testing code which relies on an external system.

Continue reading Unit Testing Code which Consumes SOAP Services »

Posted on Friday, the 10th of April, 2009 | permalink | comments (5)

Adding a Doctype Declaration to a DOMDocument in PHP

I've recently been spending quite a lot of time with PHP's DOM extension, which is extremely useful for both generating and parsing XML.

In this particular case, I'm generating XML, and it's imperative that the XML markup which the code is generating should contain a Doctype declaration (DTD). It isn't hard to do that using DOM, but it did take a little bit of hunting around in the manual and online, so here's a quick overview of how to add a Doctype declaration to a DOMDocument.

Continue reading Adding a Doctype Declaration to a DOMDocument in PHP »

Posted on Monday, the 9th of March, 2009 | permalink | comments (8)

PHP Closing Tags Considered Harmful

It may be obvious to some, but this is a mistake I still see being made a lot, and I think it's high time we got over it.

Stop using PHP closing tags. It really is that simple, and here's why.

Continue reading PHP Closing Tags Considered Harmful »

Posted on Monday, the 16th of February, 2009 | permalink | comments (3)

Syntax Highlighting with GeSHi

On this very site, I've recently started using GeSHi, to implement the rather nifty code syntax highlighting you see in posts like this and this.

I had previously been using PHP's built in highlight_string() function, but that function is only of use for highlighting PHP code! As I often seem to need to highlight other languages, it was time to turn to GeSHi.

Since I did, a couple of people have asked about ease of use, implementation and so forth, so this post is my attempt at answering those questions.

Continue reading Syntax Highlighting with GeSHi »

Posted on Thursday, the 5th of February, 2009 | permalink | comments (1)

"Working with Zend Platform" Published

Posted on Tuesday, the 30th of September, 2008 | permalink | comments (0)

August '08 Issue of php|architect Magazine Out Now

Posted on Friday, the 29th of August, 2008 | permalink | comments (0)

Presentations on Slideshare

I've been doing a bit of presenting at work recently, which has meant getting my head around making up slides (using OpenOffice, of course). It all feels a little bit Dilbert, in a way.

Anyway, there's nothing particularly groundbreaking or PlayPhone-specific about these slides, so I've put them up on Slideshare in case anyone fancies a look.

Continue reading Presentations on Slideshare »

Posted on Friday, the 22nd of August, 2008 | permalink | comments (0)

"PHP Tools for Mobile Web Development" Published

Posted on Tuesday, the 29th of July, 2008 | permalink | comments (1)

Mobilising a Website, Part 2: Strategies

In Mobilising a Website, Part 1: The Problem I noted that this site is practically unusable when viewed using the browser on a mobile handset, and that I'd like to do something about that.

This time around, I'd like to size up some of the approaches and strategies that developers can take in order to make an existing website mobile-friendly.

Continue reading Mobilising a Website, Part 2: Strategies »

Posted on Saturday, the 26th of July, 2008 | permalink | comments (1)

Benchmarking Zend Download Server

Recently I've started looking into ways that the PHP dev team in which I work can make better use of our Zend Platform installation.

For that reason, the recent Ibuildings/Zend seminar in London on the subject of "Enterprise PHP" was well timed, as it included a pretty detailed run through of a lot of what Platform has to offer.

One feature which really struck me as having the potential to bring performance benefits to one of our systems was the Zend Download Server. Back at the office, I looked into the feature, and ran a few benchmarks. Oddly though, the results don't seem to flatter Zend Download Server.

Continue reading Benchmarking Zend Download Server »

Posted on Saturday, the 12th of July, 2008 | permalink | comments (1)

Fighting Spam and Digitising Books with reCAPTCHA

When I added a comment form to this blog, I wondered how long it would be before I started getting comment spam. Then I wondered if I was flattering myself to think that spam bots would even be interested in my site.

So it's with mixed emotions that I have to admit that right now the number of spam comments I'm receiving is outstripping the number of genuine comments by a ratio of about 10:1.

The time has come to add a CAPTCHA to the comment form.

Continue reading Fighting Spam and Digitising Books with reCAPTCHA »

Posted on Saturday, the 5th of July, 2008 | permalink | comments (0)

Zend_Search_Lucene Quick Start

I recently had a spontaneous urge to add a search form to my weblog - this one you're reading right now - and it seemed like a good opportunity to have a look at Zend_Search_Lucene.

I'm really impressed with the simplicity and power of the module. Sadly the documentation, whilst extensive, isn't particularly clear - so here's a quick overview of getting Zend_Search_Lucene up and running.

Continue reading Zend_Search_Lucene Quick Start »

Posted on Tuesday, the 3rd of June, 2008 | permalink | comments (8)

My php|architect Article to be Published in June

Posted on Sunday, the 1st of June, 2008 | permalink | comments (1)

PHPTuring

Posted on Monday, the 31st of March, 2008 | permalink | comments (0)

An Introduction to Tera-WURFL

I recently added a post about Wurfl, a comprehensive open-source XML database of mobile device capabilities. I noted that actually querying Wurfl in a performant manner:

is going to be a non-trivial task, and is perhaps a topic for a further article.

Well, I guess this is that article. It's time to have a look at Tera-WURFL, which is perhaps the most popular tool for querying Wurfl programmatically - from PHP, at least.

Continue reading An Introduction to Tera-WURFL »

Posted on Tuesday, the 11th of March, 2008 | permalink | comments (3)

Managing Mobile and Non-mobile Versions of a Site Using Tera-WURFL and Zend Framework

This is a quick proof-of-concept I put together after a discussion on how to deal with running a mobile site and a 'full' web site on the same hostname in a sane way, and to transparently route user agents to the appropriate site.

Continue reading Managing Mobile and Non-mobile Versions of a Site Using Tera-WURFL and Zend Framework »

Posted on Tuesday, the 12th of February, 2008 | permalink | comments (3)