Understanding the FX Class
What is the FX Class?
More generally, what is a Class? In PHP you can write a little program that has its own functions and its own variables; it's called a Class. It's an object that you can instantiate and use whenever you want. If that's clear, you can move on; if not, keep going. You can think of a class as as specific type of object in the world around you: like a seasoned developer, a man-eating beast, a nose, or a foot. Each of these has functions (things they can do) like smell, and variables (attributes) like size and color. Objects of the same class will have the same functions — developers will have a writeCode() function — though their attributes will likely vary somewhat. As you program, it's important to keep in mind that although objects of different classes may have functions with the same name, they might do quite different things (compare the smell() functions of a nose and a foot, for example.)
The actual FX object, or class, is written in a document called FX.php. That document is in the folder that you downloaded, and is why you have to put this directory on your web server to "install" FX.
How does FX talk to FileMaker Pro?
You could talk to FileMaker Pro yourself using any web browser by typing the URL that connects you to your host (for example, fmserver.mydomain.com or 192.168.1.11), then adding onto the URL specific, FileMaker-defined, WPE¹ syntax. The WPE¹ syntax and how to use it can be found in the FileMaker® Pro documentation on Custom Web Publishing with XML.
When you use WPE¹ syntax in the URL — for example to perform a find — your web browser will connect to the server, authenticate, and load the results. The returned data, however, is formatted in XML and contains all sorts of other metadata beyond what you might have expected from your original query.
The FX class simplifies this. Giving you PHP functions very similar in name to their FileMaker® Pro counterparts, it builds the URL query for you, sends it to the server, and then parses the XML results into a beautiful PHP array.
You don’t have to know FileMaker URL syntax to use the FX Class. You don’t have to know XML. You never have to leave the PHP environment.
How do I use the FX Class?
The rest of this "Getting Started" section shows a simple PHP script that performs a find on your data source of choice using the FX Parser. Use of the FX Class is explained briefly here, with enough details to get you started. For more detail see the functions documentation.
