Guest Posted April 3, 2019 Hello all! This might be the wrong forum. Apologies. It's not about Delphi output. I know some people here uses PHP. I have also read about some integration project. DWScript transpiles Pascal to JavaScript. Otherwise that would probably be a good candidate... I have just finished a limited job for some commercial entity (not what i usually do). And every now and then when these jobs show themselves i have to fight Word-press or Drupal. As a side-note it's interesting to see how little coding competence the consultants managing these sites have. It's not the first time that a php-hater like me have to do the job for them, and the result is not 100% since i refuse to "learn" the idioms of those monsters. So this last time, googling the PHP manual, word-press codex and all i was thinking; a "plugin" that translates ObjectPascal to php! Not that i would have to google the manuals very much less, though. Something like: functions.php: <?php /** * Word-press blah blah... ... ?><?pas function SeriousCoding(var aTypedVar: string): Boolean; begin return StrToIntDef($_POST["something"], 0); end; ?><?php .... ?> or some such. Do you think it would be possible. Is there a OP to PHP transpiler project to start from? TIA, /Dany Share this post Link to post
Shaun Roselt 0 Posted June 24, 2019 I think this would definitely be possible and I would personally love this since I use WordPress almost every day. Having such a plugin would be pretty cool. It would however be a difficult plugin to write. Share this post Link to post
Markus Kinzler 174 Posted June 24, 2019 Why converting to PHP and not to HTML/JS directly? Share this post Link to post
Guest Posted June 24, 2019 2 hours ago, Markus Kinzler said: Why converting to PHP and not to HTML/JS directly? This is for the jobs that require word-press or drupal. The js is not executed on the server. PHP is. Going node.js as a base for js that in turn is pluggable into server-side code seems a bit convoluted. But perhaps it is a viable way to go. I do not know enough of PHP it's environment, wp/drupal and their respective "environment". Share this post Link to post
David Heffernan 2345 Posted June 24, 2019 Ugh. Good luck reasoning about the security of such a thing. Share this post Link to post
José León 12 Posted June 25, 2019 That recalled me a very old project of mine: https://www.youtube.com/watch?v=KjnqqeJhBEo Skip to minute 4 if you just want to see it working. Regards Share this post Link to post
Guest Posted June 25, 2019 15 hours ago, David Heffernan said: Ugh. Good luck reasoning about the security of such a thing. If i could inject a "pas" file into any Drupal php-file then i would work with Pascal that transpiles to PHP and the environment would be exactly the same. The server would actually execute php and not pascal. I cannot see why transpiled pascal would introduce attack vectors that hand-coded php do not. But i would appreciate some enlightenment. Maybe you meant Pas => HTML/JS => Node.js + Drupal server side? THAT would open up attack vectors. Yes. Share this post Link to post
Mohammed Nasman 11 Posted June 26, 2019 I read before that Intraweb 17 will support wordpress, I'm not sure how they will do the integration and if it will allow the pascal code to be executed within PHP You can give brief idea from their roadmap. https://www.atozed.com/intraweb/roadmaps/v17/ Share this post Link to post
David Schwartz 426 Posted June 28, 2019 (edited) If you're feeling ambitious, you could write an ObjectPascal interpreter that runs on Apache and acts similar to php. The challenge with that is there are elements in Delphi that have syntax and semantics that only apply to compiled code. An interpreted version of Delphi would need to be a little different. TMS Software has an interpreter that supports both BASIC and ObjectPascal syntax that you could probably use as a base for something. There's also DWScript, as was mentioned earlier. The problem with apps like WP and Drupal is they have not been written (historically speaking) in a very object-oriented manner, due to a bias lots of php coders have against OOP, believing it slows down execution time. Last I checked, Python was much slower than php (and fully OOP), yet it's use is growing extremely fast, so I guess execution speed is more of a religious issue than anything else. Then you've got all of the weird ways people do things OOP-wise with php code that would make most serious Delphi, C++, and C# coders gag. Edited June 28, 2019 by David Schwartz 1 Share this post Link to post
Rollo62 536 Posted June 28, 2019 (edited) There was an old (very interesting) product from Embarcadero around: HTLM5Builder. http://www.drdobbs.com/web-development/embarcadero-html5-builder-actually-quite/240006712 Unfortunately this is quite dead and unsupported, but its still there. The efficieny was not good enough, at that time, so the PHP crowd preferred the traditional PHP Ide's for a good reason. I would also hope that in one (long distant) future, maybe PHP will be integrated in the IDE as platform too Ok, ok, lets stop dreaming Maybe this is what you're looking for ? Edited June 28, 2019 by Rollo62 Share this post Link to post
Doug Rudd 2 Posted June 28, 2019 PHP has commands to execute a native console program. Including: exec() - Execute an external program system() - Execute an external program and display the output passthru() - Execute an external program and display raw output escapeshellcmd() - Escape shell metacharacters pcntl_exec() - Executes specified program in current process space Make a console application that does what you want, or outputs HTML. In Delphi you can now make it for Windows or Linux. You can then use it anywhere on a PHP page: <?php echo exec("myconsoleprog.exe myparameters"); ?> Share this post Link to post
Eli M. 38 Posted July 9, 2019 PHP4Delphi lets you build extensions for PHP. Pretty old though. https://sourceforge.net/projects/psvlib/files/PHP4Delphi/ Share this post Link to post