15

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

4

2 回答 2

1

尝试以下步骤:

  1. 从 github 下载 taglib 源代码
  2. 从 .csproj 文件中删除 ApplicationIcon 标记并在 Visual Studio 中打开 .sln
  3. 卸载测试项目(你不需要构建这个)
  4. 右键单击 taglib-sharp 项目 --> 属性 --> 构建 --> 启用“注册 COM 互操作”。还要清除条件编译符号文本框,这样您现在就不必费心下载 SharpZipLib。
  5. 观察 #1:在项目属性 --> 应用程序 --> 程序集信息 --> '使程序集 COM 可见' 被选中
  6. 观察 #2:在项目属性 --> 应用程序 --> 目标框架设置为 3.5(确保保持原样)
  7. 构建项目 (F6)
  8. 阅读输出窗口的内容以查看一些警告

现在您有了 src\taglib-sharp.dll,您需要将它注册到全局程序集缓存中,以便 DOTNET 类找到它。如果您对此不熟悉,请参阅PHP DOTNET hell了解详细信息。

如果一切顺利,您可以自己获取一份 SharpZipLib 副本,然后重新输入 HAVE_SHARPZIPLIB 条件编译符号 --> 重建 --> 重新部署到 GAC --> 做一个快乐的人!:)

于 2015-07-26T13:06:35.743 回答
1

You may compile you DLL with .NET Framework 3.5 if not, PHP do not be able to load it via DOTNET class.

Download .NET 3.5

于 2015-07-26T23:50:31.147 回答