Modify PHP Script Engine - Add New Script Type

#1

I have seen a couple of articles about referencing self contained classes from within the PHP scripting capability. Looking at the code, this is done via an Eval. A major disadvantage of the Eval is the ability to debug code and also Eval obviously suffers from performance issues as I understand that it is not cached in the normal way.

I am think about 2 potential ways forward to enable incorporation of PHP code into the model:
a) Alter the code in the current PHP engine to look for a class definition e.g. \myplugins\myclass::call in the script text and simply instantiate it directly (preferably with a defined interface to force method adherence)
b) Create a new ‘Php Class’ script Engine which is added to the current set of script types, leaving the current Eval approach untouched.

Option b) is probably preferable, but looking at the code for ScriptEngineManager the script types available are hard coded into the construct. Can anyone provide any advice on how to add a new script type?
Thanks
Murray

0 Likes