Note Feel free to suggest a better title as I think 'generate code' and 'abstraction' might not be the best expressions for what I want to ask :)
I'm looking for a good pattern/standard way to generate PHP code from some sort of abstraction layer.
Example
I've built a set of classes that act es text-processing filters. These filters can be chained together to transform some input-text into some other output text, e.g.
Input "Hello 'CRUEL' World"
>> RegexFilter('(.*?)') [extract everything between '']
>> ToLowerFilter [lowercase the extracted text]
Output: cruel
Resulting Code
The corresponding source code looks something like this:
$input = "Hello 'CRUEL' world";
$pattern = "#(.*?)#";
$first = new RegexFilter($pattern);
$second = new ToLowerFilter();
$first->setNextFilter($second);
$ouput = $first->Transform($input);
echo $output; // cruel
I would like to create some sort of abstraction layer, so that the end user (non-programmer) can built his own filter chain without writing code by himself. By "abstraction" I mean something like XML, JSON, stored in a database, etc.
XML example (suggestion)
<filters>
<filter name='Regex'>
<properties>
<property name='pattern'>'(.*)'</property>
</properties>
<nextfilter name='ToLower'>
<properties/>
</filter>
</filter>
</filters>
Remark: The example is very simplistic. Think of more advanced things like "complex objects as properties for filters", "inheritance of filters" (the above filter could get the name "RegexToLowerFilter" and can be referenced by other filters), etc.
Approaches / Ideas
Is there standard way to tackle this sort of problem? So far I've thought of building a custom XML, JSON, etc. serializer/deserializer for every filter but that seems like a lot of work and is potentially error prone because it's done individually for every filter. Further I guess that would require to make every possible dependency also serilizable in the same fashion - which can be problematic when using third party libraries (e.g. JsonPath).
I suppose the most elegant way would be the creation of Domain Specific Language. Unfortunately building a compiler is not the easiest task and probably not always appropriate for every problem in that space. (Then again, feel free to correct me :))
TL;DR
I'm looking for a suitable way / pattern to built an abstraction layer between the (non-progammer) end user and my source code. The solution should take the "simplified" abstraction and "generate" the corresponding code.