Prototype of integrating DM Editor with languages, PHP as main.
The benefit will be, besides visual editing for editor, being able to combine flexibility of PHP template (and database access) and DM Editor's widget (specially for interactive widgets like tabs, collapsable text, pop up and more) and it will need only one rendering implementation for both editing and viewing.
To achieve that, below should be supported:
- Allow PHP (or template) to render DM Editor.
- Allow PHP (or template) to make widget, which is loaded both in front site and admin editing. The 'php widget' may be able to embed non-php widget also.
- Support defining styles in config / js config or db (loaded externally) and implementing style in PHP template.
- [not here but in solution] a place to launch dmeditor & save.
- [not here but in solution] asset integration, including images, files, links, data source (future).
Run a nextjs server behind (mostly on localhost and proxy nextjs to client).
Pros: mature platforms
Cons:
- Need extra server (can be in localhost) to run.
- request to nextjs (embed) and request back (for widget rendering)? - maybe it's not a big deal as long as it's stable and easy to set up.
(working on this approach for now.)
Use php_v8js to run react for both server and client. Other languages - Python: pyv8, Java: j2v8, .NET: ClearScript, Go: v8go.
(PS. seems in Python community they prefer approach 1. eg. https://github.com/markfinger/python-react)
Props: native invoking - php invoking js and js invoking php (and template)
Cons:
- Complex to set up.
- Libraries for rendering js in PHP (both server and client) is not proved reliable and maintained (eg. https://github.com/Limenius/ReactRenderer).
Sub folders:
- dmeditor-lang (js library): a dmeditor widget wrapper which loads PHP templates as widget (with styles parameter), and defines styles by config.
- php (php library, symfony vendor): php wrapper for invoking DM Editor View, providing template and invoking widget rendering (for edit view).
- sample: sample project of using php lib & dmeditor-lang.
PHP developer in the end can have 2 ways to develop widget:
- For case where it's mostly static template, not much script: template (eg. twig).
- For case where it's some templating and more script: recommand to use react for both scripting and rendering (JSX), as using template + another react inside template is unnecessary (still using JQuery? then use first way :)).