Reflection in this case means examining a class to find out its properties and methods. It is a commonly available technique in object-oriented languages and is often used as a way of writing generic code that can work with a large number of classes.
The first thing you need is a web server that supports PHP, version 5. This can be the ubiquitous Apache web server for UNIX/Linux machines or IIS for Windows (although others also support PHP, these are the most common). When installing with IIS there is a choice of running the PHP processor as an out of process server using CGI or in process using ISAPI. The first method is recommended for reliability, the second for performance. For the purposes of this chapter, the ISAPI installation was chosen.
You can find the PHP installation, along with a list of compatible web servers, at http://uk.php.net. There is a comprehensive set of instructions with a list of Frequently Asked Questions detailing how to resolve some common difficulties and problems.
There are two stages involved in developing the server-side page: implementing the business classes that will do the actual processing and hooking them into the framework so that they become accessible from the client.
The first stage is to create a standard server-side skeleton page that can be used as a starting point for most JPSpan projects. This consists of the basic plumbing needed to inform JPSpan of the business class as well as other options such as what to do in the event of an error.
The second stage is the coding of the business class or classes to be used, which requires a knowledge of PHP and the syntax used to declare classes. The syntax is very similar to C++ and Java, so any knowledge of those two languages will help.
After the business class has been tested outside of the JPSpan framework, it can be incorporated into the skeleton page ready for use by the client.
The basic structure of a server-side processing page looks something like the following example:
Following the opening PHP tag is the place where the code for the actual class will be included. This can be actually in the page or can be held in a separate file and accessed through one of the PHP include mechanisms.