Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build TagLib# DLL from source and make it COM Visible to PHP

Tags:

Hello I want to scan audio-video files and store their metadata in a database using php. I found this Command-line wrapper that uses TagLib.dll compiled by banshee developpers to do the job. It's works fine but it limited by the functions implemented. I want to access directly to the dll methods via PHP.

In PHP we have a function (DOTNET) that allows me to instantiate a class from a .Net assembly and call its methods and access its properties like this :

/*$obj = new DOTNET("assembly", "classname");*/  

$stack = new DOTNET("mscorlib", "System.Collections.Stack");
$stack->Push(".Net");
$stack->Push("Hello ");
echo $stack->Pop() . $stack->Pop();

//Returns string(10) "Hello .Net";

Here is the Taglib# project sources in github

I saw many questions relatives to PHP-DLL-COM and there is some recommendations :

  • Make the dll comVisible;
  • Register the dll with regsvr32;
  • Use a module definition file similar to

;

;

DESCRIPTION     "Simple COM object"

EXPORTS
                DllGetClassObject       PRIVATE
                DllCanUnloadNow         PRIVATE
                DllRegisterServer       PRIVATE
                DllUnregisterServer     PRIVATE

My question is : How can I build the DLL and use its method via PHP ?

My config :

  • OS

    Windows Server 2012 R2 Standard Edition i586

  • Apache :

    Apache/2.2.21 (Win32) DAV/2 PHP/5.4.42 mod_ssl/2.2.21 OpenSSL/0.9.8r

  • PHP

    PHP Version : 5.4.42
    Arch : x86
    Compiler : MSVC9 (Visual C++ 2008)
    COM support : enabled
    DCOM support : disabled
    .Net support enabled

  • Microsoft Visual Studio 2013