Simon Willison’s Weblog

Subscribe
Atom feed for php

176 posts tagged “php”

2002

Warp factor PHP

I’ve been working on a PHP application that can take an XTM formatted Topic Map and convert it in to relational data in MySQL, run queries on it and convert it back to an XTM later. My work on the initial parser has involved some pretty heavy duty processing, and the speed with which PHP and MySQL are handling the data I’m throwing at them is phenomenal. The classic Italian Opera Topic Map example weighs in over a megabyte of XML, but PHP is munching it up and spitting out (and executing) over 13,000 SQL queries in less than seven seconds.

Instant PHP Web Services

XML-RPC Class Server is a really clever piece of code. It consists of a single file which you can drop in a directory full of PHP .class.php files to instantly provide an XML-RPC interface to every class in the directory. Private methods that begin with an underscore are not included in the web service. Unfortunately the system requires PHP’s XML-RPC extensions to be enabled.

PHP object overloading

I’m not sure how this one snuck under the radar, but PHP now supports object overloading (as of version 4.2.0). It can be implemented by creating class methods __set(), __get() and __call() and then applying the new overload() function to the class name. The documentation claims that __call() is not yet supported but is apparently out of date. Standard warnings about the experimental and unfrozen nature of the extension apply.

New PHP vulnerability

Vulnerability found in PHP 4.2.0 and 4.2.1 involving HTTP POST requests. The PHP group have released PHP 4.2.2 which fixes this problem.

Amazon search updated

I’ve updated PHP Amazon Search to implement a few more search methods, and altered the example script to allow searches for related items.

Fun with Amazon

There’s plenty of activity surrounding Amazon web services today. My limited demo barely scratches the surface of the possibilities—people are already experimenting with Amazon’s similarity search and Mark Pilgrim has released PyAmazon, a Python wrapper for the Amazon API. I’ve started listing alternative implementations on the PHP Amazon Search page, and I’ll be sure to blog the more innovative examples as and when I find them.

Amazon web services

Amazon have launched a brand new web service interface to their huge database of products. I’ve been playing around with it, and I’ve knocked together a simple search engine example in PHP, with the code available for anyone who wants it. I did a similar thing a few months ago when Google released their Web API so we’ve set up a new site at Incutio to host these and other open source projects—scripts.incutio.com. The site is only a few hours old and we’d love some feedback—contact us directly or add a comment to this entry.

Blogchat rocks

I spent a while today over at Brent Ashley’s blog chatting away on BlogChat. BlogChat is Brent’s impressive DHTML chat system (backend in PHP, front end via JSRS) which allows anyone visiting his blog to talk to him (and other visitors) in real time, provided he is online to host the session. During the afternoon I got to talk to people from all over the world, all with similar interests because they all had the same taste in blogs. I am hoping to install a version of Brent’s system on this site in the not-too-distant future.

Python in PHP

Python in PHP (via HarryF on the SitePoint Forums):

[... 123 words]

Wiki fun

Yesterday I set up a Wiki for Smarty as well. I like Wikis. The WikiEngine used for Smarty and MACCAWS is called TaviWiki, and is implemented in PHP with a MySQL back end. I had previously deployed PhikiWiki for a couple of university projects, which is good in that it is the only PHP Wiki I know of that works from the file system, but bad in that it has no support for version tracking (essential if your Wiki is accessible to the public).

Smarty at OSCON

Smarty at OSCON: Andrei Zmievski and Sterling Hughes will be presenting a tutorial titled “Template Architectures with Smarty” at the O’Reilly Open Source Convention in San Diego, July 22-26, 2002. Further details are available here. Smarty is a powerful template engine for PHP which combines a highly versatile templating language with excellent performance gained through template compilation.

Busy day

Quiet blogging day today, but I’ve been busy behind the scenes. Firstly I’ve been playing around with TaviWiki (an excellent PHP Wiki engine), using it as a proof of concept for a Wiki-driven small website content management system. I’ve looked at several PHP Wiki’s in the past and TaviWiki is the best by far, with rock solid features and a well organised code base. My only criticism is that the script relies on globals a bit too much, making it quite hard to figure out what is going on at times. I’ve also been working on IncDirectory, the open source sequel to my aging links directory script ssLinks. Add to that a new CSS experiment and preliminary work on rewriting this blog to use mySQL and today has been my most productive in quite some time.

PHP XML Classes

PHP XML ClassesA collection of classes and resources to process XML using PHP. Includes PHP implementations of Xquery lite and RDQL along with parsers for RDF, RSS and RDDL.

Rasmus Lerdorf’s blog

Rasmus Lerdorf (the creator of PHP) has a blog. His latest entry discusses Palladium, and asks if it will actually help build up the alternative market of non wintel users.

PHP form problem

I’m suffering from a bizzare PHP bug. For some reason, POSTed form entries over a certain length are being lost when submitted to scripts running on this site. Here is a demo script which demonstrates the problem—try typing in a short chunk of text and it will submit fine, but anything long (seemingly over about 1300 characters) will be mysteriously lost. The server’s PHP Info output is available. If you have any idea what could be causing this drop me a line or add a comment to this entry.

PHP auto class inclusion

When developing PHP applications, I usually have a classes directory somewhere in which I keep all of my PHP classes ready for inclusion. I name the class files ClassName.class.php. Normally I have a common.inc.php file that is included in all of the scripts in my application and requires the classes needed by the application, but today I wrote a few lines of code that saves me from having to alter that file every time I write a new class:

[... 154 words]

Kuro5hin on AudioGalaxy

Kuro5hin are running a fascinating story on AudioGalaxy, written by one of the AudioGalaxy developers who wrote a large portion of the web interface code. It covers the history of the system and its recent demise at the hands of the RIAA, with quite a few technology pointers as well (they used PHP to serve over 90 million hits a day).

Installing PHP and XSL on Windows

I’m currently reinstalling PHP on my Windows machine, and in doing so I came across this tutorial: Installing XSL and PHP on Windows. The tutorial provides all the necessary files and instructions to get XSL working with minimum hassle. I’ve been meaning to play with XSL for some time, and this has provided me with just the boost I needed to give it a go.

PHP string tip

I’ve lost count of the number of times I’ve posted this PHP tip on a forum somewhere, so I may as well blog it:

[... 86 words]

Andrei interview

Interview with Andrei Zmievski on SitePoint. Andrei is the guy behind PHP-GTK, the project that enables developers to write client side GUI applications using PHP. He is also one of the two lead developers on Smarty, the world’s greatest PHP templating engine. Oh, and he’s contributed various bits to PHP itself, including Perl compatible regular expressions and WDDX support. All that and he still has time for an interest in the history of western culture ;) The interview makes great reading for anyone interested in PHP, and also provides a link to a web server written in PHP.

PHP Documentor

phpDocumentor version 1.1.0rc2 has been released over at www.phpdoc.org. The feature list (from their press release):

[... 136 words]

Blog fixed

I’ve just finished rebuilding the main data file for this blog, after it became corrupted last night due to a “Disk Quota Exceeded” error. It looks like this was my fault—I inadvertantly filled up my disk space when I was playing around with libxml and PHP choked when it tried to save the latest update to my blog. Luckily no data was permanently lost as the archives are cached as flat files, which allowed me to rebuild the data file from scratch.

[... 109 words]

My first XHTML mind bomb

I’ve been looking at PHP’s XML handling functions (in particular the xml_parse() function) and I’ve suddenly realised the advantages of writing entries in valid XHTML. Before I started this blog one of the features I considered adding was something that can pull all of the links out of an entry when it is submitted and index them or add them to a directory somewhere. I was preparing myself for some regular expression hacking, but thanks to XHTML this is now completely unnecessary. All I need to do is define a couple of handlers to deal with <a> tags and Expat will do the hard work for me. In fact, this approach gives me a great deal of flexibility in what I do with my entries. I can extract quotes and blockquotes, pick up on emphasized text and generally allow my blog software to “understand” my entries as and when I add them. The true benefits of XHTML have suddenly become clear.

Zend Engine 2 alpha

I don’t know how I missed this, but the PHP group have released an alpha version of PHP with the Zend Engine 2 (tarball / Windows binary). This is exciting stuff—the new scripting engine has vastly improved object support and brand new exception handling, something I’ve wanted in PHP for a long time. The CHANGELOG lists the new features and provides sample code. Here’s a summary:

[... 248 words]

Todo list

Weblog TODO List

I’ve got the bare bones of a weblog up and running now— essentially the ability to add entries which are categorised and archived in a permanent location. Still to come...
  1. An edit function
  2. A comments system (probably similar to Jonathan Delacour’s)
  3. RSS feeds for individual categories
  4. Referral tracking (as seen on diveintomark)
  5. A better form of overall statistics tracking than that provided by the University
  6. A system for storing more permanent feature articles
  7. An XML-RPC API for posting with an accompanying PythonCard application
  8. An interface for editing my Blog Roll
  9. Allow visitors to include/exclude categories via cookies
  10. A preview post feature
  11. A link directory that accumulates links automatically by parsing blog entries
  12. Dancing monkeys—definitely dancing monkeys
This blog is written in PHP and uses serialized PHP objects in flat text files for storage. I will put together a full article on how everything works as soon as I’ve implemented a “permanent feature” archive.

Blogging aint easy

Blogging isn’t nearly as easy as it looks. After several days hacking around in PHP (I’m far too proud to use an off the shelf solution) I find myself confronted with a blank slate, and writers block has taken hold. The toughest thing is working out what style to use in blog entries—my previous writing for the web has been primarily on forums (where posts do not have to stand on their own) or news sites where a formal, unopinionated tone is required. A blog should be informal but informative, with each post hopefully adding a new angle to the topic in hand. I’m sure it will get easier as I go along...