PHP Macro
Rendering macro to execute PHP script |
Type | JAR |
Category | |
Developed by | |
Active Installs | 43 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Compatibility | Require XWiki 6.4 or more. |
Table of contents
Description
Macro used as an entry point to execute PHP script. It's based on Quercus PHP engine and synchronized on its versions.
Usage
Unlike the other scripting languages available for XWiki, PHP is a semi-templating scripting language, which means that it must explicitly wrap code sections inside <?php ?> markers:
Parameters definition
See the Script Macro for details.
Example 1
Result:
Hello World!
Example 2
{{php}} Some static content inside the PHP macro,
<?php echo("and some dynamic content."); ?> {{/php}}
Example 3
Calling Java methods.
Result:
xwiki:CurrentSpace.CurrentDocument
Limitations
A current limitation of the Quercus library is that variables and class definitions are only valid inside the same macro block.
$i will be visible inside the same macro block:
<?php echo ($i); ?>
The correct value of i will be printed, 5.
{{/php}}
Unfortunately, here $i will not be valid:
{{php}} <?php echo ($i); ?> {{/php}}
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Release Notes
v4.0.66
v4.0.65.1
v4.0.65
v4.0.63
v4.0.46
- The extension is now a Contrib extension synchronized on Quercus versions.
- Upgraded to Quercus 4.0.46
Dependencies
Dependencies for this extension (org.xwiki.contrib:macro-php 4.0.66):
- org.xwiki.platform:xwiki-platform-rendering-macro-script 6.4
- com.caucho:quercus 4.0.66