I’m developing an web based application written in PHP5, which basically is an UI on top of a database. To give users a more flexible tool I want to embed a scripting language, so they can do more complex things like fire SQL queries, do loops and store data in variables and so on. In my business domain Python is widely used for scripting, but I’m also thinking of making a simple Domain Specific Language. The script has to wrap my existing PHP classes.
I’m seeking advise on how to approach this development task?
Update: I’ll try scripting in the database using PLPGSQL in PostgreSQL. This will do for now, but I can’t use my PHP classes this way. Lua approach is appealing and seems what is what I want (besides its not Python).
If you are not bound to python, you could use for example Lua as scripting language. Lua is a very lightweight language, easy to learn, and developed with embedding in mind. There are already at least two PHP extensions available, which nicely embed Lua into PHP and therefore provide the possibility to allow access between PHP and Lua part of your application. Have a look at:
http://pecl.php.net/package/lua
This one also has some nice examples:
http://phplua.3uu.de/
I’ve already used the latter one a bit for simple experiments and it works quite good.