本文整理汇总了PHP中Composer\Package\Package::setTargetDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::setTargetDir方法的具体用法?PHP Package::setTargetDir怎么用?PHP Package::setTargetDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\Package
的用法示例。
在下文中一共展示了Package::setTargetDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComposerPackage
/**
* @param string $version
* @param string $vendorDir
* @return Package
*/
public function createComposerPackage($version, $vendorDir)
{
$package = new Package($this->package, $version, $version);
$package->setTargetDir($vendorDir);
$package->setInstallationSource('dist');
$package->setDistType($this->getPlatform() == 'linux' ? 'tar' : 'zip');
$package->setDistUrl($this->getDownloadUrl($version));
return $package;
}
示例2: createComposerInMemoryPackage
public static function createComposerInMemoryPackage($targetDir, $version)
{
$url = self::getURL($version);
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version);
$package = new Package(self::PHANTOMJS_NAME, $normVersion, $version);
$package->setTargetDir($targetDir);
$package->setInstallationSource('dist');
$package->setDistType(pathinfo($url, PATHINFO_EXTENSION) === 'zip' ? 'zip' : 'tar');
// set zip, tarball
$package->setDistUrl($url);
return $package;
}
示例3: install
/**
* Installation package
*
* @param Composer $composer
*/
public function install(Composer $composer)
{
$this->init();
/* Create Composer in-memory package */
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($this->version);
$package = new Package($this->name, $normVersion, $this->version);
$package->setInstallationSource('dist');
$package->setDistUrl($this->url);
$package->setDistType($this->distType);
$package->setTargetDir($this->targetDir);
/* Download the Archive */
$downloadManager = $composer->getDownloadManager();
$downloadManager->download($package, $this->targetDir, false);
/* Copy binary to the "bin" file */
$binDir = $composer->getConfig()->get('bin-dir');
$this->copyToBinFolder($binDir);
}
示例4: testGetTargetDir
public function testGetTargetDir()
{
$package = new Package('a', '1.0.0.0', '1.0');
$this->assertNull($package->getTargetDir());
$package->setTargetDir('./../foo/');
$this->assertEquals('foo/', $package->getTargetDir());
$package->setTargetDir('foo/../../../bar/');
$this->assertEquals('foo/bar/', $package->getTargetDir());
$package->setTargetDir('../..');
$this->assertEquals('', $package->getTargetDir());
$package->setTargetDir('..');
$this->assertEquals('', $package->getTargetDir());
$package->setTargetDir('/..');
$this->assertEquals('', $package->getTargetDir());
$package->setTargetDir('/foo/..');
$this->assertEquals('foo/', $package->getTargetDir());
$package->setTargetDir('/foo/..//bar');
$this->assertEquals('foo/bar', $package->getTargetDir());
}
示例5: installPhantomJS
/**
* Operating system dependend installation of PhantomJS
*/
public static function installPhantomJS(Event $event)
{
$composer = $event->getComposer();
$version = self::getVersion($composer);
$url = self::getURL($version);
$binDir = $composer->getConfig()->get('bin-dir');
// the installation folder depends on the vendor-dir (default prefix is './vendor')
$targetDir = $composer->getConfig()->get('vendor-dir') . self::PHANTOMJS_TARGETDIR;
// Create Composer In-Memory Package
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version);
$package = new Package(self::PHANTOMJS_NAME, $normVersion, $version);
$package->setTargetDir($targetDir);
$package->setInstallationSource('dist');
$package->setDistType(pathinfo($url, PATHINFO_EXTENSION) === 'zip' ? 'zip' : 'tar');
// set zip, tarball
$package->setDistUrl($url);
// Download the Archive
$downloadManager = $composer->getDownloadManager();
$downloadManager->download($package, $targetDir, false);
// Copy only the PhantomJS binary from the installation "target dir" to the "bin" folder
self::copyPhantomJsBinaryToBinFolder($targetDir, $binDir);
}
示例6: install
/**
* Operating system dependend installation of CasperJS
*/
public static function install(Event $event)
{
//Install PhantomJs before CasperJs
\PhantomInstaller\Installer::installPhantomJS($event);
$composer = $event->getComposer();
$version = self::getVersion($composer);
$url = self::getURL($version);
$binDir = $composer->getConfig()->get('bin-dir');
// the installation folder depends on the vendor-dir (default prefix is './vendor')
$targetDir = $composer->getConfig()->get('vendor-dir') . self::CASPERJS_TARGETDIR;
// Create Composer In-Memory Package
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version);
$package = new Package(self::CASPERJS_NAME, $normVersion, $version);
$package->setTargetDir($targetDir);
$package->setInstallationSource('dist');
$package->setDistType('zip');
$package->setDistUrl($url);
// Download the Archive
$downloadManager = $composer->getDownloadManager();
$downloadManager->download($package, $targetDir, false);
// Create CasperJS launcher in the "bin" folder
self::createCasperJsBinaryToBinFolder($targetDir, $binDir);
}
示例7: installPhantomJS
/**
* Operating system dependend installation of PhantomJS
*/
public static function installPhantomJS(Event $event)
{
$composer = $event->getComposer();
$version = self::getVersion($composer);
$url = self::getURL($version);
// Create Composer In-Memory Package
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version);
$package = new Package(self::PHANTOMJS_NAME, $normVersion, $version);
$package->setTargetDir(self::PHANTOMJS_TARGETDIR);
$package->setInstallationSource('dist');
$package->setDistType(pathinfo($url, PATHINFO_EXTENSION) === 'zip' ? 'zip' : 'tar');
// set zip, tarball
$package->setDistUrl($url);
// Download the Archive
//$io = $event->getIO();
//$io->write('<info>Fetching PhantomJS v'.$version.'</info>');
$downloadManager = $composer->getDownloadManager();
$downloadManager->download($package, self::PHANTOMJS_TARGETDIR, false);
// Copy all PhantomJS files to "bin" folder
// self::recursiveCopy(self::PHANTOMJS_TARGETDIR, './bin');
// Copy only the PhantomJS binary to the "bin" folder
self::copyPhantomJsBinaryToBinFolder($composer);
}
示例8: testUseGlobalIncludePath
public function testUseGlobalIncludePath()
{
$package = new Package('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => '')));
$package->setTargetDir('Main/Foo/');
$this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
$this->configValueMap['use-include-path'] = true;
$this->fs->ensureDirectoryExists($this->vendorDir . '/a');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'IncludePath');
$this->assertFileEquals(__DIR__ . '/Fixtures/autoload_real_include_path.php', $this->vendorDir . '/composer/autoload_real.php');
}
示例9: testMainPackageAutoloadingWithTargetDirAndNoPsr
public function testMainPackageAutoloadingWithTargetDirAndNoPsr()
{
$package = new Package('a', '1.0', '1.0');
$package->setAutoload(array('classmap' => array('composersrc/')));
$package->setTargetDir('Main/Foo/');
$this->repository->expects($this->once())->method('getPackages')->will($this->returnValue(array()));
$this->vendorDir .= '/subdir';
$this->fs->ensureDirectoryExists($this->vendorDir . '/composer');
$this->fs->ensureDirectoryExists($this->workingDir . '/src');
$this->createClassFile($this->workingDir);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDirNoPsr');
$this->assertAutoloadFiles('classmap2', $this->vendorDir . '/composer', 'classmap');
}
示例10: activate
public function activate(Composer $composer, IOInterface $io)
{
$installer = new PlatformInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
// Look for extra platform-installer definition
$pi = false;
$package = $composer->getPackage();
$config = $composer->getConfig();
$extra = $package->getExtra();
if (!empty($extra['platform-installer'])) {
$pi = $extra['platform-installer'];
}
if (false === $pi) {
return;
}
// Cycle through platform installers
$installNow = array();
foreach ($pi as $platform => $installer) {
if ('all' === strtolower($platform)) {
foreach ($installer as $install) {
if (!empty($install['url'])) {
if (empty($install['dir'])) {
$install['dir'] = $config->get('vendor-dir') . '/steveorevo/platform/' . strtolower($platform);
}
if (!is_dir($install['dir'])) {
array_push($installNow, $install);
}
}
}
} else {
foreach ($installer as $install) {
if (empty($install['dir'])) {
$install['dir'] = $config->get('vendor-dir') . '/steveorevo/platform/' . strtolower($platform);
}
// Check for architecture
$arch = "";
if (substr($platform, -3) === "_64" || substr($platform, -3) === "_32") {
$arch = substr($platform, -3);
$platform = substr($platform, 0, -3);
}
// Prevent matching 'win' within 'Darwin' and computer name conflicts on Mac
$uname = php_uname();
if (PHP_OS === "Darwin") {
$platform = str_ireplace('Darwin', 'Macintosh', $platform);
$uname = str_ireplace('Darwin', 'Macintosh', $uname);
$uname = str_ireplace(gethostname(), '', $uname);
}
if (false !== stripos($uname, $platform)) {
if ($arch !== "") {
if ($arch === '_' . 8 * PHP_INT_SIZE) {
if (!is_dir($install['dir'])) {
array_push($installNow, $install);
}
}
} else {
if (!is_dir($install['dir'])) {
array_push($installNow, $install);
}
}
}
}
}
}
// Download platform installers
foreach ($installNow as $install) {
$targetDir = $install['dir'];
$url = $install['url'];
$downloadManager = $composer->getDownloadManager();
$version = $package->getVersion();
$versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version);
$package = new Package($url, $normVersion, $version);
$package->setTargetDir($targetDir);
$package->setInstallationSource('dist');
if (false === strpos($url, '.zip')) {
$package->setDistType('tar');
} else {
$package->setDistType('zip');
}
$package->setDistUrl($url);
try {
$downloadManager->download($package, $targetDir, false);
} catch (\Exception $e) {
if ($e instanceof \Composer\Downloader\TransportException && $e->getStatusCode() === 404) {
$io->write("<warning>File not found: {$url}</warning>");
} else {
$io->write("<warning>Error downloading: {$url}</warning>");
}
}
}
}