Trypticon Strudel.


PHP-Mesh is covered by the GNU Lesser General Public License.

(Save) Download PHP-Mesh v1.4 FINAL

Note: as PHP-Mesh is now what I would consider feature-complete, From here on I will work on some more documentation and a more fully-fleshed example. I just need to free some time up to do this.

If you use PHP-Mesh, and you like it, please give me some feedback. If you don't like it, give me even more feedback. :-)

What Is It?

PHP-Mesh is a basic framework for meshing together content of web pages with the style which they appear in on the user's screen.

In a way, this accomplishes a task similar to XSLT, where you write a single stylesheet to enable simpler development of the pages which contain the actual content.

The idea was taken from the wonderful SiteMesh, made by OpenSymphony for Java.

Why Bother?

Well, the need for something like this came about when I started to move from my home-built Java-based web servers out onto the general web. Many sites only provide for PHP, and the extremely clean nature of SiteMesh is simply too good to give up.

Of course, you could just include headers and footers. But the problem is, you have to include these headers and footers in every page. This won't seem like a problem to you until you're given the job of converting 100 or more pages, and then, what happens when you change the name of the header file? 100 pages to convert all over again.

Another option is to just write all pages as the bit between the <body> and </body> tags. This is also less than desirable because it relies on the assumption that headers and footers will be automatically included. Since you no longer have a full HTML page, you can't test the pages offline, and you can't validate them either (a clean site is a validated site, right?)

So then you have various options. You could write XSLT and suffer the pain of massive development costs (even if just in terms of personal time.) You could try and CSS all the pages, but CSS has a tendency of needing code in the HTML to hook it in (at the very least, it requires a <link/> element in the page header at the very least, and usually a few class attributes scattered through the HTML itself.

Clearly there must be a better way.

Enter PHP-Mesh.

Ease of Installation

PHP-Mesh requires no modification to pages which are to be meshed, though at the present time, the only pages which can be handled this way are .php or plain .html files.

Installation requires copying the contents of the package to some location on your server, and then editing two files in the root of your web documents directory. Then you need to write a 'decorator' (terminology borrowed from SiteMesh), which is effectively a stylesheet but a lot less complicated than XSLT.

Some knowledge of PHP is required to write your own decorator, although the sample provided should provide even beginners with a jump start to writing their own. There is also a start to documenting the main Page class.


I appreciate feedback. For bug reports, feature requests and all other comments, see the menu for my contact details.