Data Injection Markup Language
How to use DIML from PHP
Author: V.G. FREMAUX
E.I.S.T.I. / Cergy, France
Applied Research Laboratory (EARLY)
Version: 1.0 / July 2003
The necessity to bring DIML concepts available from PHP was motivated by the extreme popularity of such a language. This implementation intends to :
- allow full portability of the DIML pages from a Perl implementation to a PHP driven server, with the lowest reengineering cost.
- allow a PHP based "overscripting", that should be more accessible to many developpers in the world.
- be closely attached to the development of further PHP libraries, and have benefit of this langage dynamism.
- have most benefits of the Zend* engine optimizations.
However, the global meaning of the DIML language remains unchanged: a sane separation between the design world, methods and way of thinking, and the pure hard soft universe. DIML will provide PHP users with a nice tool for designing clear and highly readable implementations, that will have much lowered maintaining time.
(*) Someone could tell me how Perl version performances were so superior ?.
The PHP version of the DIML Engine is quite similar to the Perl version. It complies to the same language specification, and is a direct translation of the Perl 2.6 version, allowing :
- The core specification processing.
- External script invocation (PHP overscripting)
- DIML language extensions add-ons (SQL, XML, etc.)
The major difference between both versions is the way the external scripting API (overscripting) is presented. Only overscripting authors should be concerned. They are resumed below :
Perl Implementation |
Php Implementation |
The interface hash linking the Perl overscripts to the DIML is the global associative array %main::ESSInput. All DIML templates and variables are available as an entry in this table. |
The Php global associative array $ESSInput serves as interface between overscripts and the DIML Engine. It has the same purpose as the hereleft table. |
The INVOKE statement invokes Perl overscripts written as additional Perl files (".pl" files) that will be run in the perl module scope "ESSI" (invocation uses a perl "do"). |
The overscripts are written as PHP includes in ".php" files. The PHP sequence will have to be written between standard PHP markers (invocation is performed as an "include()"). |
Conditioanl expression use all syntactic possibilities of the Perl language, as they are evaluated through the "eval" just-in-time interpreter. |
Conditional expressions use all resources of the PHP syntax, as they are evaluated through the PHP "eval" just-in-time interpreter. For better compatibility, some typical Perl syntaxes are transcoded to PHP, and will be still recognized. |
The HTTP invocation of the DIML Engine is an external CGI processing attached to a new Type definition. On Apache, it may be setup using the AddType/Action directive pair. It is copatible with many HTTP servers presenting a standard CGI external redirection. |
The Php invocation uses Apache's mod_rewrite module, as detailled in the following installation instructions. |
The PHP verison of the DIML engine processes files with entextion .pdim (standing for "PhpDiml"). The proposed Mime Type for these files remains unchanged (application/x-essi-parsed). The output Mime Type is mostly text/html, unless explicit configuration.
The PHP implementation is provided as a set of Php scripts:
ESSI.php |
The Engine's wrapper. It retrieves sufficient information in the request to localize and start the processing of the template.
|
ESSIConf.php |
The configuration file. Gives all configuration settings for the DIML Processor.
|
ESSIParser.php |
Main Engine. The main interpretor (core specification).
|
ESSIGen.php |
General utilities library. Functions quite usefull in many places.
|
ESSICgi.php |
CGI Adaptor. Translates CGI variables in the DIML scope. Has a set of fucntino CGI related.
|
ESSIWct.php |
Web Component Strategy special library. Specific functions for dealing with the "Web Component" model.
|
ESSIXml.php |
XML Extension. Additional module.
|
ESSISql.php |
SQL Extension. Additioanl module.
|
This script set can be placed in any directory PHP enabled.
".pdim" files redurection uses Apache's dynamic URL rewriting module, known as mod_rewrite. Following directives should be placed into a server context* in httpd.conf (from the 1.3.9 version):
RewriteEngine on
RewriteRule ^(.*\.pdim)(.*)$ http://{URL_to_DIML_PHP}/ESSI.php?org=%{SCRIPT_FILENAME} [R,QSA,L]
RewriteRule ^(.*\.pdim)$ http://{URL_to_DIML_PHP}/ESSI.php?org=%{SCRIPT_FILENAME} [R]
That might be completed by:
RewriteLog logs/rewrite.log
RewriteLogLevel 1
For logging control.
(*) This may be either a main server context or a virtual host context to serve .pdim files within the whole hostname scope.
Once Apache has restarted, the validation file dimltest_short.pdim can be browsed to test the response of the processor to most standard DIML syntaxes.
All material is copyleft V.G. FREMAUX (EISTI France) 1999 to 2003 except explicitly mentioned
|