diff --git a/lib/MelodyPlugin.php b/lib/MelodyPlugin.php index f66fca4..93fbf1f 100644 --- a/lib/MelodyPlugin.php +++ b/lib/MelodyPlugin.php @@ -4,6 +4,7 @@ use SensioLabs\Melody\Melody; use SensioLabs\Melody\Configuration\RunConfiguration; use Symfony\Component\Process\Process; use SensioLabs\Melody\Resource\ResourceParser; +use Symfony\Component\Process\ExecutableFinder; /** * Class which integrates melody scripts into the php-console. @@ -17,9 +18,14 @@ class MelodyPlugin { } public function isScriptingSupported() { - // the melody lib is bundled with the console, so the only additional requirement is a composer CLI - exec('which composer', $out, $ret); - return $ret === 0; + $executableFinder = new ExecutableFinder(); + foreach (['composer', 'composer.phar'] as $candidateName) { + if ($composerPath = $executableFinder->find($candidateName, null, array(getcwd()))) { + return true; + } + } + + return false; } public function runScript($__source_code, $__bootstrap_file) @@ -56,4 +62,4 @@ class MelodyPlugin { file_put_contents($tmpFile, $__source_code); $melody->run($tmpFile, array(), $configuration, $executor); } -} \ No newline at end of file +}