So I’m a little confused about the status of XSLTProcessor::registerPHPFunctions in Symphony 2.0.7. I want to implement some native PHP 5 functions in XSLT (such as date formatting and regex).

I found Ashooner’s EXSL Function Manager extension, but it doesn’t quite seem to be what I want. It seems more suited for extension developers. And if I read the release notes for 2.0.7 correctly, it looks like it’s possible to register PHP functions—but again, only through an extension.

When I add the xmlns:php namespace to my template and try to use a PHP function, the XSLT processor throws an error:

XSLTProcessor::transformToXml(): xsltExtFunctionTest: PHP Object did not register PHP functions

So Symphony 2.0.7 does not register the native PHP functions by default, correct? Is there a way to do this without writing a whole extension for it?

I’m OK with hacking a part of the core; I’m just not familiar enough with the code to know where to begin. This is just for my personal site, so I’m not too concerned about portability. Of course, if a more elegant solution exists, I’d much prefer that.

Once the Symphony engine gets to XSLT stage, all the PHP has been run. If you want to run PHP functions, you’re going to have to run them at Datasource level, so an extension is most probably required.

PS, I asked the same ‘type’ of question here a while back…

So Symphony 2.0.7 does not register the native PHP functions by default, correct?


I’ve developed an extension called Datestamp Helper, and you can take it as an example to create your own functions. See the source code, really simple.

Edit: By the way, I didn’t try the EXSL Function Manager extension yet. I’ll have a look on it.

As far as I can see, you can access within an event the Page object. Register your functions there and you’re done. A simple approach if you don’t want to write a custom extension.

Create an event and replace the body of the load function with something like that:



Frontend::instance()->Page()->registerPHPFunction(array('trim', 'strlen'));

Of course the event needs to be attached to any page you wish to use your functions in. Not tested but should work.

Thanks for the tips. Alpacaaa, your suggestion to use a custom event works like a charm.

And thanks for the encouragement, rainerborene. You’re right; the extension approach doesn’t look nearly as scary as I had envisioned.

I’ve been spending so much time learning XSLT that I haven’t looked under the hood much at writing custom events, datasources, and extensions. Then again, that’s probably a testament to Symphony’s power.

Now I can have my PHP cake and eat it too.

I posted an article on this subject. It might be useful to Symphony neophytes who want to be able to call PHP functions from their XSL.

Ok, I understand, has created a new Data Sources, and what to do next? Prescribed xslt. But where I see the result of transformation?

Thank you all very much.

In the other thread you asked about using built-in PHP functions. That is what this thread and my article are mostly about. It now seems like you might be trying to build your first Symphony site. As phoque suggested in the other thread, have you worked through the tutorials yet?

Generally, the next step after creating a data source is to create a page where the data provided by the data source will be displayed. When you create a page a starter xsl file will be placed in the workspace/pages directory. Make sure that when you create the page that you attach the data source to the page.

In case anyone in 2017 or even the future likes to read the above mentioned article, it’s still readable at

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details