Extension:PhpTags

From MediaWiki.org
Jump to: navigation, search

Other languages:
العربية • ‎català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil • ‎русский • ‎sicilianu • ‎中文
PhpTags - navigation (viewTemplate:PhpTags navigation)
Basics Main pageExtension:PhpTags (talk) · Magic expressionsExtension:PhpTags/Magic expressions · Quick start guideExtension:PhpTags/Quick start guide · For developersExtension:PhpTags/For developers · PerformanceExtension:PhpTags/Performance · Examples · Try to use it
Optional installationExtension:PhpTags#Optional installation CodeMirrorExtension:CodeMirror · PhpTags Debugger
Additional installationExtension:PhpTags#Additional installation PhpTags WikiExtension:PhpTags Wiki · PhpTags FunctionsExtension:PhpTags Functions · PhpTags WidgetsExtension:PhpTags Widgets · PhpTags Maps
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
PhpTags

Release status:Extension status beta

ImplementationTemplate:Extension#type Tag, Parser function, Hook
DescriptionTemplate:Extension#description Allows users to use the Magic expressions with PHP language syntax
Author(s)Template:Extension#username Pavel Astakhov (pastakhovtalk)
Latest versionTemplate:Extension#version 5.5.0 (2015-11-20)
MediaWikiTemplate:Extension#mediawiki 1.25+
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
ExampleTemplate:Extension#example test.foxway.org
ParametersTemplate:Extension#parameters
  • $wgPhpTagsMaxLoops
  • $wgPhpTagsNamespaces
  • $wgPhpTagsBytecodeExptime
TagsTemplate:Extension#tags
phptag
Hooks usedTemplate:Extension#hook
ParserFirstCallInitManual:Hooks/ParserFirstCallInit
UnitTestsListManual:Hooks/UnitTestsList
ParserLimitReportManual:Hooks/ParserLimitReport
PhpTagsRuntimeFirstInit
ParserAfterTidyManual:Hooks/ParserAfterTidy
ArticleDeleteCompleteManual:Hooks/ArticleDeleteComplete
PageContentSaveCompleteManual:Hooks/PageContentSaveComplete
CodeMirrorGetExtensionMode

Translate the PhpTags extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The PhpTags extension implements the concept of Magic expressions with PHP language syntax that allows you to create and use compatible but not monolithic MediaWiki extensions, which greatly increases the convenience, flexibility and performance. More ...

Description[edit]

The PhpTags extension has its own the runtime environment PHP code which supports scalar types, arrays, variables, operators, control structures. It also supports constants, functions and objects but it does not implement any of them except for some language constructs.

When using a function, object or constant PhpTags calls corresponding extension. Therefore, a set of constants, functions, objects and actions that they produce only depend on additionally installed compatible extensions which can be found here.

PhpTags designed so to be as similar to native PHP, therefore you should have the illusion of direct execution PHP code although this never happens.

Usage[edit]

The code should be placed between the tags <phptag> and </phptag>. It can be located in any namespace if it is allowed by the variable $wgPhpTagsNamespaces.

<phptag>
$foo = 'hello world';
echo ucfirst( $foo . "!!!\n" );
</phptag>

It will display:

Hello world!!! 

Demo

Note Note: the function ucfirst is implemented in Extension:PhpTags_Functions.

More details can be found in the quick start guide.

Installation[edit]

Manual installation

  • Download and place the file(s) in a directory called PhpTags in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/PhpTags/PhpTags.php";
    
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Optional installation[edit]

@todo

Additional installation[edit]

The PhpTags extension (core) implements magic expressions only and not, for instance, any PHP function.

For additional features such as functions, you can install additional extensions which are compatible with the magic expressions of the PhpTags extension.

The main extensions are:

Others are Extension:PhpTags SMW and Extension:PhpTags Storage.

Configuration parameters[edit]

$wgPhpTagsMaxLoops
Maximum number of allowed loops (by default it is 1000 loops)
$wgPhpTagsNamespaces
Array of namespaces in which the PhpTags extension is allowed to use. Boolean true allows usage in all namespaces (it is set by default)
$wgPhpTagsBytecodeExptime
Storage time of the compiled bytecode in cache, by default it is 2592000 seconds (30 days)