PHP:在Composer包中使用Phing任务

时间:2015-06-29 00:43:51

标签: php build composer-php phing

我已经创建了一个Composer包,并在其中定义了一个扩展Task的自定义Phing任务。在我的包含Composer包的项目中,我希望能够在我的构建文件中使用此Phing任务,但我一直收到此错误:

mBluetoothAdapter.startLeScan(mLeScanCallback);

我的构建文件尝试使用" generateview"任务:

   [taskdef] Error importing generateViews\GenerateView.php
[PHP Error] include_once(generateViews\GenerateView.php): failed to open stream: No such file or directory [line 1058 of C:\Users\Me\Downloads\phing-2.4.13\classes\phing\Phing.php]

[PHP Error] include_once(): Failed opening 'generateViews\GenerateView.php' for inclusion (include_path='C:\Users\Me\Downloads\phing-2.4.13\bin/../classes;.;C:\php\pear') [line 1058 of C:\Users\Me\Downloads\phing-2.4.13\classes\phing\Phing.php]
BUILD FAILED
Error reading project file [wrapped: Error importing generateViews\GenerateView.php]
Total time: 0.1742 seconds



Build finished at 6/28/2015 8:35 PM with exit code 0.

这是我的实际任务:

<taskdef name="generateview" classname="generateViews.GenerateView" />

 <target name="viewgenerator" >
    <echo msg="Generating View: ${absname}" />
    <generateview name="${absname}"/>
</target>

这是composer.json的自动加载部分。这是我真正不确定的部分。

namespace tasks\generateViews;

class GenerateView extends \Task {

如果有帮助,我的项目结构如下:

"autoload": {
  "psr-0": {
    "MyProject": "src/",
    "tasks": "src/tasks",
    "generateViews": "src/tasks/generateViews"
  }
}

1 个答案:

答案 0 :(得分:2)

找到答案。

我需要将它添加到我的构建文件中:

<php expression="include('vendor/autoload.php')"/>

我将GenerateView.php文件添加到自动加载类映射中,如:

   "classmap": ["src/tasks/generateViews/GenerateView.php"],