Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Call .DLL functions from PHP5?

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've written a series of class libraries using .NET that parse websites and store the information in classes.

I would really hate to have to convert that code to php now that we have decided to go php on a linux system.

Is there a way to use my DLL's functions and class objects from php, on a Linux OS?

Thanks,

Justin
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it uses .NET, then it's a DLL only by file extension, but internally it's a .NET assembly containing .NET CIL and requires a .NET runtime.
I don't think there's any easy way to use it as is on a Linux system.
A .NET compatible runtime named Mono exists for linux systems, but I haven't tried it out. You may want to look at that first.

An option to explore is source code conversion tools - C# to PHP, or C# to C++ to PHP. But I suspect, it won't be simple if you're using .NET class libraries.

Is the interface to that class library very verbose, or is it minimal and simple?
If it's minimal, then the least effort way to use it is to introduce a web service adaptor for that simple interface, deploy it in a windows machine (can be a virtual machine on that same linux system if you're using a single linux system)
and talk to it as a regular http web service via query params and receive XML or JSON or some textual representation that PHP can parse easily. There may be a performance penalty though, due to all that network traffic.

If it's a verbose interface, then tough luck - because writing a web service adaptor for it may become as cumbersome as rewriting all that logic in PHP.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I've been looking around and figured I'll either just go with ASP.Net or rewrite API in PHP and go that way.

Thanks for the explanation : )

Justin.
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic