From 74da2f673015504f0bb01873be244e4038e64487 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 3 Jul 2012 10:43:34 +0200 Subject: [PATCH 1/2] Remove unnecessary code --- src/Composer/Installer/PearInstaller.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Composer/Installer/PearInstaller.php b/src/Composer/Installer/PearInstaller.php index 47ed4f70b..c4e7182bc 100644 --- a/src/Composer/Installer/PearInstaller.php +++ b/src/Composer/Installer/PearInstaller.php @@ -28,8 +28,6 @@ use Composer\Util\Filesystem; */ class PearInstaller extends LibraryInstaller { - private $filesystem; - /** * Initializes library installer. * @@ -41,7 +39,6 @@ class PearInstaller extends LibraryInstaller */ public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library') { - $this->filesystem = new Filesystem(); parent::__construct($io, $composer, $type); } From 3bdae180f6552bdff5b04605d5c61d60d1c83472 Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Wed, 4 Jul 2012 00:38:29 +1100 Subject: [PATCH 2/2] Add php proxies that add all locally installed packages to include_path. PEAR binaries are run through these proxies. --- src/Composer/Installer/PearInstaller.php | 51 ++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/Composer/Installer/PearInstaller.php b/src/Composer/Installer/PearInstaller.php index c4e7182bc..6b0655122 100644 --- a/src/Composer/Installer/PearInstaller.php +++ b/src/Composer/Installer/PearInstaller.php @@ -31,10 +31,8 @@ class PearInstaller extends LibraryInstaller /** * Initializes library installer. * - * @param string $vendorDir relative path for packages home - * @param string $binDir relative path for binaries - * @param DownloadManager $dm download manager * @param IOInterface $io io instance + * @param Composer $composer * @param string $type package type that this installer handles */ public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library') @@ -89,4 +87,51 @@ class PearInstaller extends LibraryInstaller return $binaries; } + + protected function initializeBinDir() + { + parent::initializeBinDir(); + file_put_contents($this->binDir.'/composer-php', $this->generateUnixyPhpProxyCode()); + chmod($this->binDir.'/composer-php', 0777); + file_put_contents($this->binDir.'/composer-php.bat', $this->generateWindowsPhpProxyCode()); + chmod($this->binDir.'/composer-php.bat', 0777); + } + + private function generateWindowsPhpProxyCode() + { + return + "@echo off\r\n" . + "setlocal enabledelayedexpansion\r\n" . + "set BIN_DIR=%~dp0\r\n" . + "set VENDOR_DIR=%BIN_DIR%..\\\r\n" . + " set DIRS=.\r\n" . + "FOR /D %%V IN (%VENDOR_DIR%*) DO (\r\n" . + " FOR /D %%P IN (%%V\\*) DO (\r\n" . + " set DIRS=!DIRS!;%%~fP\r\n" . + " )\r\n" . + ")\r\n" . + "php.exe -d include_path=!DIRS! %*\r\n"; + } + + private function generateUnixyPhpProxyCode() + { + return + "#!/usr/bin/env sh\n". + "SRC_DIR=`pwd`\n". + "BIN_DIR=`dirname $(readlink -f $0)`\n". + "VENDOR_DIR=`dirname \$BIN_DIR`\n". + "cd \$BIN_DIR\n". + "DIRS=\"\"\n". + "for vendor in \$VENDOR_DIR/*; do\n". + " if [ -d \"\$vendor\" ]; then\n". + " for package in \$vendor/*; do\n". + " if [ -d \"\$package\" ]; then\n". + " DIRS=\"\${DIRS}:\${package}\"\n". + " fi\n". + " done\n". + " fi\n". + "done\n". + "cd \$SRC_DIR\n". + "`which php` -d include_path=\".\$DIRS\" $@\n"; + } }