1 | <?php |
||
8 | class RoboFile extends \Robo\Tasks |
||
|
|||
9 | { |
||
10 | /** |
||
11 | * Run All Unit Test |
||
12 | */ |
||
13 | public function test() |
||
18 | |||
19 | |||
20 | /** |
||
21 | * Build phar executable. |
||
22 | */ |
||
23 | public function pharBuild() |
||
24 | { |
||
25 | // Create a collection builder to hold the temporary |
||
26 | // directory until the pack phar task runs. |
||
27 | $collection = $this->collectionBuilder(); |
||
28 | $workDir = $collection->tmpDir(); |
||
29 | $buildDir = "$workDir/neuralyzer"; |
||
30 | |||
31 | $prepTasks = $this->collectionBuilder(); |
||
32 | $preparationResult = $prepTasks |
||
33 | ->taskFilesystemStack() |
||
34 | ->mkdir($workDir) |
||
35 | |||
36 | ->taskCopyDir([ |
||
37 | __DIR__ . '/src' => $buildDir . '/src' |
||
38 | ]) |
||
39 | |||
40 | ->taskFilesystemStack() |
||
41 | ->copy(__DIR__ . '/bin/neuralyzer', $buildDir . '/bin/neuralyzer') |
||
42 | ->copy(__DIR__ . '/composer.json', $buildDir . '/composer.json') |
||
43 | ->copy(__DIR__ . '/composer.lock', $buildDir . '/composer.lock') |
||
44 | ->copy(__DIR__ . '/LICENSE', $buildDir . '/LICENSE') |
||
45 | ->copy(__DIR__ . '/README.md', $buildDir . '/README.md') |
||
46 | |||
47 | ->taskComposerInstall() |
||
48 | ->dir($buildDir) |
||
49 | ->noDev() |
||
50 | ->noScripts() |
||
51 | ->printed(true) |
||
52 | ->optimizeAutoloader() |
||
53 | ->run(); |
||
54 | |||
55 | // Exit if the preparation step failed |
||
56 | if (!$preparationResult->wasSuccessful()) { |
||
57 | return $preparationResult; |
||
58 | } |
||
59 | |||
60 | // Decide which files we're going to pack |
||
61 | $files = \Symfony\Component\Finder\Finder::create()->ignoreVCS(true) |
||
62 | ->files() |
||
63 | ->name('*.php') |
||
64 | ->name('*.exe') // for 1symfony/console/Resources/bin/hiddeninput.exe |
||
65 | ->path('src') |
||
66 | ->path('vendor') |
||
67 | ->notPath('docs') |
||
68 | ->notPath('/vendor\/.*\/[Tt]est/') |
||
69 | ->in(is_dir($buildDir) ? $buildDir : __DIR__); |
||
70 | |||
71 | // Build the phar |
||
72 | return $collection |
||
73 | ->taskPackPhar('neuralyzer.phar') |
||
74 | ->addFile('bin/neuralyzer', 'bin/neuralyzer') |
||
75 | ->addFiles($files) |
||
76 | ->executable('bin/neuralyzer') |
||
77 | ->taskFilesystemStack() |
||
78 | ->chmod(__DIR__ . '/neuralyzer.phar', 0755) |
||
79 | ->run(); |
||
80 | } |
||
81 | } |
||
82 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.