PHP Macro

Last modified by Admin on 2017/12/11 00:06

php_file.icoRendering macro to execute PHP script
TypeJAR
Developed by

Thomas Mortagne, XWiki Development Team

Active Installs16
Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Compatibility

Require XWiki 6.4 or more.

Installable with the Extension Manager

Description

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

{{php}}<?php echo 'Hello World!'; ?>{{/php}}

Result:
 Hello World!

Example 2

Some *wiki* content.
{{php}} Some static content inside the PHP macro,
<?php echo("and some dynamic content."); ?> {{/php}}

Limitations

A current limitation of the Quercus library is that variables and class definitions are only valid inside the same macro block.

{{php}} <?php $i = 5; ?>
$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). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

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.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.46):

  • org.xwiki.platform:xwiki-platform-rendering-macro-script 6.4
  • com.caucho:quercus 4.0.46
Tags:
Created by Thomas Mortagne on 2016/08/30 16:55
    

Get Connected