PHP XML Repository 0.1.1 - aka XMLEngine

Distributed under GNU Public License (GPL)

Copyright 2002 Matthew Berry

SourceForge Logo

Downloads on SourceForge

INTRODUCTION

This package grew out of the need of a friend and former client of mine. He was
and still is developing a large scale application that needed to be completely
abstracted from technology in terms of the storage of its data. XML was his
choice, he needed a structured repository which operated in flat XML files in a
directory tree. This way he was able to update the files from any application,
via FTP or HTTP if necessary.

The main interface would be his intra/extranet application. His application
server supported PHP and I was tasked with making some form -> XML functions.
In order to make the repository really useful though some type of search and
retrieve functions needed to be implemented. That is when I enlisted the help
of the fantastic php.XPath class, available on SourceForge.

Having created a searchable repository, I wanted to network it, so that in the
future my client's distributed application could expand. In order to do this I
split the repository into Server and Client classes and created an XML-RPC
server to do the rest. Well, it works pretty well. I had to add a few bits and
bobs here and there - authentication, for example - but it worked pretty well.

So here it is, make of it what you will. You might need to learn a little XPath
to let you query it. Check out the resources section later in the document.

If you use PHP XML Repository, or would like to offer comments or suggestions,
please contact me on matt@dataactive.co.uk

FILES IN THE PACKAGE

The package contains all the necessary files to run and is split into
3 subpackages. The tree below, which took a long time to create(!), shows the
structure.

+--+ PACKAGE
   `-- example.php
   `-- license.txt
   `-- README.txt
   `-- XMLEngine_conf.php
   |
   `-+ INCLUDES
   | `-- xmlrpc.inc.php
   | `-- xmlrpcs.inc.php
   | `-- XPath.class.php
   | `-- XMLEngine_Client.php
   | `-- XMLEngine_Server.php
   | `-+ FUNCTIONS
   |   `-- authenticate.inc.php
   |   `-- fetch.inc.php
   |   `-- fetch_multi.inc.php
   |   `-- is_registered.inc.php
   |   `-- query.inc.php
   |   `-- register.inc.php
   |   `-- remove.inc.php
   |   `-- store.inc.php
   |   `-- remove.inc.php
   |
   `-+ DOC (documentation)
   | `-- lots of html files
   |
   `-+ RPCSERVER
   | `-- rpcserver.php
   | `-- XMLEngine_conf.php
   | `-+ ADMIN
   |   `--+ index.php
   |
   `-+ DATA
     `-- objects.xml
     `-- users.dat
     `-+ CACHE
     `-+ INDEXES
     `-+ TOKENS


INSTALLATION

1:  Download the latest phpxmlrep_*.tar.gz or .zip archive from
    SourceForge.

2:  Extract it all to your home directory or where ever you like

3:  Copy the entire contents of the includes directory to somewhere in your
    include_path. Make sure you also copy the whole functions directory "as is"
    to ensure that the structure remains the same.

Set up the repository
---------------------

4:  Decide where you want your xml repository to be located. Create a directory
    there called xmlroot. I will refer to it as /path/to/xmlroot

5:  Decide where you want your data files to be kept. This is users.dat,
    objects.xml some other bits and bobs. Create a directory there called data
    e.g. /path/to/data and copy the contents of the data directory in the
    server package to it, including all subdirectories (cache,indexes,tokens)

NOTE: xmlroot and data will have to be readable by your scripts. If you are
      using an Apache module on Linux, you will have to make sure that the web
      server has read/write access here. On my Mandrake box I ran

        $ chown -R nobody 
        $ chmod -R 770 
      
      which works because the server runs as nobody. You can find out who your
      server runs as by creating a script with  in.

***
NOTE: If you don't want to network your repository, don't do the next step
***

If you are going to connect to this repository from another machine or by rpc,
you need to set up an rpc server.

6:  Copy the contents of the rpcserver directory to a location in your web tree
    so that it can be reached from the network.
    You should have something like http://yourserver.com/xml/rpcserver.php
    and also http://yourserver.com/xml/XMLEngine_conf.php
    and also http://yourserver.com/xml/admin/index.php (htpasswd this dir!)

    Edit the _conf.php file to reflect your /path/to/xmlroot and /path/to/data
    Your repository is now accessible over the network.

Set up a client
---------------

7:  To use the repository you need to use the client. You have, in fact,
    created a client already, if you created the rpc server in step 6.
    The admin directory contains a file that acts as a locally connected
    client for admin tasks. Only locally connected clients can perform some
    tasks, so that is what that page is for.

    If your client is on the same host as the repository, you can start using
    it right away. Just copy an XMLEngine_conf.php file to your directory,
    or put one in the include_path with the other includes, and edit it to
    reflect the /path/to/xmlroot and /path/to/data locations. Now you can
    start using the repository by including the XMLEngine_Client.php file.
    See example.php for more info.

    If your client is on another host, you need to need to copy the includes
    to the include_path on that machine. Now include XMLEngine_Client.php in
    you PHP scripts, connect_remote( ... ) and off you go.
    See example.php for more info.


RESOURCES

Checkout the API documentation included with this release for info on the
client functions. Also you will need to get used to XPath for querying the
repository.

Have a look at the XPath Tutorial on http://www.ZVON.org which will get you
started.

Queries to the repository have two comoponents path:query. Path is the path
under which you wish to search, eg / will search all documents. query must be
a valid XPath query.

For example queries see the QUERIES.txt file included in the package.