0

Not quite sure what to even call what I am trying to do. I am working on a CRM product in PHP which needs to have asynchronous scriptable workflows to be embed-able to that the clients using the software will be able to perform custom tasks on certain triggers, similar to the way workflows operate in Microsoft Dynamics CRM but as a scripted process rather than a visually designed process (would have preferred visual but I imagine that would be exceptionally harder to do as an embeded option.

As an example each time a record status changes the following psuedo code would be run asyncronously...

BEGIN WORKFLOW
    IF status = ARCHIVED THEN
        new email(to, from, subject, body)
        new sms(to, from, message)
   END IF
END WORKFLOW

However I do this I need the ability to be able to add handlers so that the scripting engine can have added functions added to it that work with my code and the entire workflow needs to be encapsulated in a way that it is context aware of the record which initiated the workflow. I am not after software recommendations as that isn't allowed on here as far as I am aware, I am after being pointed in the right direction on how to do this.

I know that I could theoretically just do it all in PHP and let PHP be used as the workflow language but am not wanting to expose all PHP functions or enable the workflows to affect the standard operating of the main application, the scripted workflows would have to be sandboxed and restricted so that not only can they only work with data which has been exposed to them but they can also only use methods which I define for them to use and not have access to the full range of PHP methods or be able to perform actions outside the application control such as including additional files.

I know that I could also simply design a plugin framework that would handle this easily but would rather have it done as a simplified scripting engine, similar in concept to VBA where you can use programming but only to extend the current file within the application and there are restrictions on what can be done.

Any help would be appreciated.

Chris Rutherfurd
  • 1,617
  • 1
  • 15
  • 32
  • maybe this can help you: http://www.antlr.org/ or see http://stackoverflow.com/questions/8002617/php-lexer-and-parser-generator – agassner Jul 08 '16 at 12:52
  • If you are to make something like this beware of the [inner-platform effect](https://en.wikipedia.org/wiki/Inner-platform_effect) – apokryfos Jul 08 '16 at 12:53
  • I think you're trying to implement a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language), there are plenty of metaprogramming plattforms for this, you can try [MPS](https://www.jetbrains.com/mps/) they also support visual editing, depending on how complex this will get i would consider an easier approach – fehrlich Jul 08 '16 at 12:58

0 Answers0