Using packages in XP

at 2006-10-14 in Editorial by admin (0 comments)

Since RFC #0074 the XP framework has the built-in power to load classes from an class archive.

Now, imagine you want to install an XP application like dialog, and you have downloaded an tar file containg the application from the project's homepage. What do you do with it?

Basically, all you have to do is to put the file into PHP's include_path configuration setting. You can do this by changing php.ini or by appending -dinclude_path=... to the command line. For a web application, I'd put it into the local php.ini or the .htaccess file.

But back to the example. This is how you'd "install" dialog. First unpack your distribution file:


alex@found ~/dialog $ tar xzvf /home/alex/dialog.tar.gz
bin/
bin/converters/
[...]


The distribution file comes with a .xar archive that is located in the classes/ subdirectory. This file must be added to the include_path of the virtualhost configuration.

This could be done through an .htaccess file or directly in httpd.conf. I usually do the latter, so this is what my virtualhost configuration looks like:


VirtualHost dialog.example.com:
RewriteEngine on
RewriteRule ^/xml/([a-zA-Z]+)[.:;]([a-zA-Z_]+)([.:;]psessionid=([0-9A-Za-z]+))?/([0-9a-zA-Z/]+)$ /index.php \
[E=PRODUCT:$1,E=LANGUAGE:$2,E=SESS:$4,E=STATE:$5,PT]

DocumentRoot /home/alex/dialog/doc_root/
php_admin_value include_path /home/alex/dialog/classes/dialog.xar:/home/alex/dialog/doc_root/

SetEnv DEF_PROD dialog
SetEnv DEF_LANG en_US


The important line is the bold one describing the include_path. The include_path points to two places: one "dialog.xar" and into the doc_root. The file dialog.xar is the class archive containing all classes required for execution of the XP framework and the dialog application.
The doc_root directory does, of course, contain index.php; in addition to that, it was also chosen to contain the lang.base.php file. This does not need to be like that, it could also live somewhere else - just one include_path must point to the file.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases

Related

Find related articles by a search for «Using».