So, another in a series of posts where I package up some code I often use into a reusable library, let me introduce a simple PHP library for creating virtual pages.

Virtual pages are pages on a website that are generated in code, and are sent to the client’s browser, but don’t correspond directly to a physical file. This process requires mod_rewrite on Apache, but similar functionality exists in other web servers.

Defining your endpoint

You must specify your endpoint, and then a handling function. This function can be anything callable; functions, methods or an enclosure.

Writing your endpoint handler

You then trigger the handled pages by writing a page handler, and then directing Apache to redirect unhandled requests to this endpoint.

Example endpoint:

And your redirect code:

Hopefully this’ll be useful to someone!

» Visit the project on Github...

Over on GitHub I have just open sourced a PHP web and web services framework which I’ve been making use of to build a lot of projects recently.

Initially, it was built for a single project but I’ve ended up using it for many other things, and I thought it might be useful to the Open Source community.

Features

  • Pluggable
  • Light weight
  • Sophisticated events system
  • Abstracted database layer
  • MVC architecture
  • Virtual pages
  • Object/Metadata based data model

Its designed to have much of its functionality carried in plugins, many of which I will release a little bit later just as soon I’ve had the time to tidy them up a bit!

Anywho, its available under the MIT licence and hopefully it’ll be useful to you!

» Github Project Page (Core Plugins, Extra Plugins)