By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

Coding a PHP5 extension with Visual Studio .NET

P: n/a
I have a custom piece of code that I need to call from PHP5, so I'm going to
write an extension that will handle things for me. This is becoming
urgent - my original plan didn't work out and I'm posting something here
before thoroughly looking on-line.

Anyone know of source code for an extension that I can modify and get to
work for my app? The stuff I've seen is for PHP4 and seems to require a
bunch of Unix tools to operate (not a "show stopper", but I'd prefer as few
steps as possible). I imagine that someone out there has PHP5 extension
sample source code that I can compile into a DLL using MS Visual Studio .NET
2003...

Okay, back to the research.
Thanks,
Lee
LeeStewart @ gmail.com


Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Lee Stewart <leestewart@nospam_gmail.com> wrote:
Anyone know of source code for an extension that I can modify and get to
work for my app? The stuff I've seen is for PHP4 and seems to require a
bunch of Unix tools to operate (not a "show stopper", but I'd prefer as few
steps as possible). I imagine that someone out there has PHP5 extension
sample source code that I can compile into a DLL using MS Visual Studio .NET
2003...


So if you are targetting the windows platform, why create a dll? Go for
COM or .net stuff (http://www.php.net/manual/en/ref.com.php)
Jul 17 '05 #2

P: n/a
"Daniel Tryba" <pa**********@invalid.tryba.nl> wrote:
So if you are targetting the windows platform, why create a dll? Go for
COM or .net stuff (http://www.php.net/manual/en/ref.com.php)


That was the first attempt - for some reason the COM objects that I'm
accessing causes PHP5 to crash. I've been able to get the object loaded, but
only if I don't use the TLB file (using com_load_typelib() ). At that point
I can't access any of the methods of this object, since PHP can't resolve
them and tells me "Call to undefined method com::Open()". Calls to
com_load_typelib() on the object tells me "Unable to find typeinfo using the
parameters supplied".

I'm able to access a bunch of other COM servers, for some reason this one is
giving me fits. I'm running out of time...
Thanks for the quick reply,
Lee
LeeStewart @ gmail.com
Jul 17 '05 #3

P: n/a
Just use one of the simpler extensions (like WDDX) that comes with the
source tarball as a starting point.

To create an extension you need to compile PHP first. The process for
version 5 is incredibly painful on Win32, because of dependency on
multiple third-party packages. Have fun :-)

Jul 17 '05 #4

P: n/a
> Just use one of the simpler extensions (like WDDX) that comes with the
source tarball as a starting point.
That's what I ended up doing - the default skeleton is way too complicated.
Ten minutes of making a new DLL and coping a little source code from other
projects seemed easier than installing awk, etc.

To create an extension you need to compile PHP first. The process for
version 5 is incredibly painful on Win32, because of dependency on
multiple third-party packages. Have fun :-)


Actually, I used the header and lib files from the source tarball, but I
copied the extension DLL into the php5/ext directory and use dl() to load
it - no recompile of any PHP server code. Everything works fine and when
I'm done I'll add my extension to php.ini and make the install permanent.
Now if I can only get the C code to call a COM object...
Thanks for the input,
Lee
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.