www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - PHP embedded in D.

reply Joshua <savagejoshua gmail.com> writes:
Greetings All,

Well I am now learning D and as part of the process I am making a GA in D for a
game I am working on. Since the games scripting is in PHP and Ruby I need a way
to run these scripts in D. Has anyone tried using something like PHP-embed in D?

I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly. 

Thanks.
Jul 03 2007
next sibling parent reply "Anders Bergh" <anders1 gmail.com> writes:
On 7/4/07, Joshua <savagejoshua gmail.com> wrote:
 Greetings All,

 Well I am now learning D and as part of the process I am making a GA in D for
a game I am working on. Since the games scripting is in PHP and Ruby I need a
way to run these scripts in D. Has anyone tried using something like PHP-embed
in D?

 I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly.

 Thanks.

You can convert the PHP headers to D modules manually or using a tool such as htod or bcd.gen, and use the PHP API directly in D. -- Anders
Jul 03 2007
parent reply Joshua <savagejoshua gmail.com> writes:
Hate to sound so newbish but is there a tutorial on how to do that? I think I
understand what you are saying but I have not tried it with anything like PHP
before. 

Anders Bergh Wrote:

 On 7/4/07, Joshua <savagejoshua gmail.com> wrote:
 Greetings All,

 Well I am now learning D and as part of the process I am making a GA in D for
a game I am working on. Since the games scripting is in PHP and Ruby I need a
way to run these scripts in D. Has anyone tried using something like PHP-embed
in D?

 I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly.

 Thanks.

You can convert the PHP headers to D modules manually or using a tool such as htod or bcd.gen, and use the PHP API directly in D. -- Anders

Jul 03 2007
parent reply Kirk McDonald <kirklin.mcdonald gmail.com> writes:
Joshua wrote:
 Anders Bergh Wrote:
 You can convert the PHP headers to D modules manually or using a tool
 such as htod or bcd.gen, and use the PHP API directly in D.

Hate to sound so newbish but is there a tutorial on how to do that? I think I understand what you are saying but I have not tried it with anything like PHP before.

Yes, there is a basic tutorial here: http://digitalmars.com/d/htomodule.html Tools like htod and bcd.gen (the latter is newer and probably better) automate much of the process. You'll still have to go through the generated modules by hand, but they'll do much of the grunt work. -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org
Jul 03 2007
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Kirk McDonald wrote:
 Joshua wrote:
 Anders Bergh Wrote:
 You can convert the PHP headers to D modules manually or using a tool
 such as htod or bcd.gen, and use the PHP API directly in D.

Hate to sound so newbish but is there a tutorial on how to do that? I think I understand what you are saying but I have not tried it with anything like PHP before.

Yes, there is a basic tutorial here: http://digitalmars.com/d/htomodule.html Tools like htod and bcd.gen (the latter is newer and probably better) automate much of the process. You'll still have to go through the generated modules by hand, but they'll do much of the grunt work.

bcd is more likely to work because it uses a complete compiler front-end (gcc-xml) to parse the source. If you go for BCD and you're on Windows, don't overlook this precompiled version here: http://dsource.org/projects/bcd/browser/downloads (Didn't used to be linked from the BCD page ... maybe it is now) I never got around to trying BCD, though, so don't ask me for a tutorial. But if you do get it working you should definitely write a tutorial so I can read it. :-) --bb
Jul 03 2007
prev sibling next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Joshua wrote:
 Greetings All,
 
 Well I am now learning D and as part of the process I am making a GA in D for
a game I am working on. 

GA -- you mean a Genetic Algorithm?
 Since the games scripting is in PHP and Ruby I need a way to run these scripts
in D. Has anyone tried using something like PHP-embed in D?
 I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly. 

Nope. PyD is the most advanced binding library right now as far as I know. Never heard about someone using PHP as an embedding scripting language for D or anything else, actually. --bb
Jul 03 2007
prev sibling next sibling parent "Anders Bergh" <anders1 gmail.com> writes:
On 7/4/07, Joshua <savagejoshua gmail.com> wrote:
 Hate to sound so newbish but is there a tutorial on how to do that? I think I
understand what you are saying but I have not tried it with anything like PHP
before.

 Anders Bergh Wrote:

 On 7/4/07, Joshua <savagejoshua gmail.com> wrote:
 Greetings All,

 Well I am now learning D and as part of the process I am making a GA in D for
a game I am working on. Since the games scripting is in PHP and Ruby I need a
way to run these scripts in D. Has anyone tried using something like PHP-embed
in D?

 I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly.

 Thanks.

You can convert the PHP headers to D modules manually or using a tool such as htod or bcd.gen, and use the PHP API directly in D. -- Anders


http://www.digitalmars.com/d/1.0/htomodule.html This page explains it all. Basically, D supports the C ABI so it can use existing C libraries, however it does not support C headers. You need to translate those into D modules. -- Anders
Jul 03 2007
prev sibling parent Alan Knowles <alan akbkhome.com> writes:
Using PHP embed, you should be able to initiate a PHP session, quite 
easily.
This is some of my very old code, that should give you an idea of how to 
use it in C
http://cvs.php.net/viewvc.cgi/pecl/bcompiler/examples/embed/

I would recommend writing a small C wrapper and then binding that. - as 
then you dont have to deal with the Macro expansion in D.

Interacting with the PHP script once running would be very difficult, as 
PHP's backend is a monster of Macro's which work in different ways 
depending on the various build options. And the whole action of creating 
variables, symbols etc. uses them throughout.

In essence you could easily use D as a controller to start up PHP 
scripts using phpembed, but I would not bother doing any more than that..
- you may as well just use PHP cli scripts.. and pass data in other ways..

Regards
Alan




Joshua wrote:
 Greetings All,
 
 Well I am now learning D and as part of the process I am making a GA in D for
a game I am working on. Since the games scripting is in PHP and Ruby I need a
way to run these scripts in D. Has anyone tried using something like PHP-embed
in D?
 
 I can use the PHP CLI if I really must but I would prefer just using the some
sort of PHP api directly. 
 
 Thanks.

Jul 03 2007