Alternatives to PHP s Native Functions:What You Should Know

I l @ ve RuBoard

Alternatives to PHP's Native Functions:What You Should Know

Before getting into the details of different PHP-XML implementations , I'd like to take a few minutes to answer a very basic question, one which may already have occurred to you: Why, really, do you need to know about alternatives to PHP's built-in XML functions?

The short answer? Most of the time, you don't. As demonstrated in previous chapters of this book, PHP comes with a remarkably full-featured library of functions designed to streamline the process of creating, parsing, and processing XML documents. These functions address most of the tasks XML developers have to grapple with ”everything from parsing and formatting XML documents to using XML to represent and pass data between systems ”in a simple and efficient manner, and are frequently updated to keep pace with emerging XML technologies and new develop-ments in the field.

As you've seen, though, many of PHP's XML extensions aren't enabled by default, and activating them typically requires you to recompile your PHP build. As long as you're working in a development environment that's controlled by you, this isn't a big deal ”you can just reconfigure PHP and compile a new build that supports the functions you need (instructions for doing this are available in Appendix A, "Recompiling PHP to Add XML Support"). But when you're working in an environment that isn't under your control (for example, your web hosting provider's Internet server), then the situation gets a little more complicated.

There are a couple of very important differences between developing software on a system you control, and developing software on a system controlled by someone else. In the former case, you typically have superuser privileges, which allow you to compile and install anything you like, whenever and wherever you like, on the system. Superuser privileges also allow you to customize the development environment to your needs, altering system configuration files and environment variables with abandon, and to update system libraries with newer versions as they become available.

Web hosting services, especially those that host multiple domains on a single server, are far less accommodating to developers. Such services typically decide on a standard development environment for each server, and offer this standard package to all customer web sites hosted on that server. This development environment may not have all the features you need; in fact, it may not even contain all the software you need! But as one customer among many, there's not much you can do about it.

Sensitive to both security and performance issues, most hosting services are also loathe to install "bleeding-edge" software on their systems (or let you do it for them). This can seriously hamper your ability to develop software that takes advantage of new features in vibrant, rapidly evolving open source projects. And, because your activities on these shared servers are restricted, you're again dependent on your service provider for software updates and upgrades. Some providers make it a point to update their software every few months, whereas others are far less attentive to the problem (and their customers).

Of course, this problem can easily be solved by throwing money at it: Buy (or rent) a server of your own, hook it up to the Internet, and download-compile-install to your heart's content. Most professional software development companies adopt this approach; however, smaller companies and independent developers may not find it economically viable .

When it comes to PHP, the problem is exacerbated by the diverse range of extensions and libraries available for the language. The standard PHP build offered by your hosting service may not be tuned to your specific needs or contain support for all the extensions you require ”and, most of the time, your only option is to grin and bear it.

Or is it?

In the best traditions of open source software, the PHP developer community is constantly creating and releasing new and innovative PHP libraries to the Web. Some of these libraries are specifically targeted at developers working with XML and PHP and are produced as alternatives to PHP's native XML functions. All of them are available free of charge and can be integrated into a PHP application with minimal difficulty (you don't need to recompile your PHP build to use them, which makes them very useful in restricted development environments). If you're faced with the kind of situation described previously, and if your pleas for a software upgrade are falling on deaf ears, you might find them handy. Take a look.

Buyer Beware!

It should be noted at the outset that this chapter is neither an exhaustive list of XML/PHP alternatives available on the Web, nor a definitive API reference or programming guide to the software implementations showcased within it. Given the speed at which new software appears (and disappears) online, such an attempt would invariably be both incomplete and inaccurate. Rather, the goal of this chapter is merely to demonstrate some of the alternatives available to XML/PHP developers, and to briefly discuss (via examples and code listings) how they may be used in application development.

Note also that all the implementations discussed in this chapter require a PHP build that has been compiled with basic XML support. This support is included by default in PHP 4.x.

I l @ ve RuBoard


XML and PHP
XML and PHP
ISBN: 0735712271
EAN: 2147483647
Year: 2002
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net