本文整理汇总了PHP中Composer\Package\Package::setDistType方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::setDistType方法的具体用法?PHP Package::setDistType怎么用?PHP Package::setDistType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\Package
的用法示例。
在下文中一共展示了Package::setDistType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addDistToPackage
/**
* @param \Composer\Package\Package $package
*/
public function addDistToPackage(\Composer\Package\Package $package)
{
$this->initializeData();
$versionDigits = explode('.', $package->getPrettyVersion());
if (count($versionDigits) === 3) {
$branchVersion = $versionDigits[0] . '.' . $versionDigits[1];
$patchlevelVersion = $versionDigits[0] . '.' . $versionDigits[1] . '.' . $versionDigits[2];
if (isset($this->data[$branchVersion]) && isset($this->data[$branchVersion]['releases'][$patchlevelVersion])) {
$releaseData = $this->data[$branchVersion]['releases'][$patchlevelVersion];
if (isset($releaseData['checksums']['tar']['sha1']) && isset($releaseData['url']['tar'])) {
$package->setDistType('tar');
$package->setDistReference($patchlevelVersion);
$package->setDistUrl($releaseData['url']['tar']);
$package->setDistSha1Checksum($releaseData['checksums']['tar']['sha1']);
}
}
}
}
示例4: 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);
}
示例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: doUpdateItself
/**
* @param array $tag
* @param Composer $composer
* @param OutputInterface $output
*/
protected function doUpdateItself(array $tag, Composer $composer, OutputInterface $output)
{
$output->writeln('Discovered a new version of the application: <info>' . $tag['name'] . '</info>');
// create install package
$package = new Package('anime-db/anime-db', $tag['version'], $tag['name']);
$package->setDistType('zip');
$package->setDistUrl($tag['zipball_url']);
$package->setInstallationSource('dist');
// download new version
$target = sys_get_temp_dir() . '/anime-db';
$this->getContainer()->get('filesystem')->remove($target);
$composer->download($package, $target);
$new_package = $composer->getPackageFromConfigFile($target . '/composer.json');
$dispatcher = $this->getContainer()->get('event_dispatcher');
// notify about downloaded
$dispatcher->dispatch(StoreEvents::DOWNLOADED, new Downloaded($target, $new_package, $composer->getRootPackage()));
// rewriting the application files
$this->rewriting($target);
// notify about updated
// event will be sent after the update application components
$this->getContainer()->get('anime_db.event_dispatcher')->dispatch(StoreEvents::UPDATED, new Updated($new_package));
$composer->reload();
$output->writeln('<info>Update itself has been completed</info>');
}
示例7: 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);
}
示例8: build
public function build(Addon $addon)
{
$composer = $this->packagist->getComposer();
$downloader = $composer->getDownloadManager();
$packageVersions = $this->packagist->getPackageVersions($addon->Name);
$time = time();
if (!$packageVersions) {
throw new Exception('Could not find corresponding Packagist versions');
}
// Get the latest local and packagist version pair.
$version = $addon->Versions()->filter('Development', true)->first();
foreach ($packageVersions as $packageVersion) {
if ($packageVersion->getVersionNormalized() != $version->Version) {
continue;
}
$path = implode('/', array(TEMP_FOLDER, self::ADDONS_DIR, $addon->Name));
// Convert PackagistAPI result into class compatible with Composer logic
$package = new Package($addon->Name, $packageVersion->getVersionNormalized(), $packageVersion->getVersion());
$package->setExtra($packageVersion->getExtra());
if ($source = $packageVersion->getSource()) {
$package->setSourceUrl($source->getUrl());
$package->setSourceType($source->getType());
$package->setSourceReference($source->getReference());
}
if ($dist = $packageVersion->getDist()) {
$package->setDistUrl($dist->getUrl());
$package->setDistType($dist->getType());
$package->setDistReference($dist->getReference());
}
$this->download($package, $path);
$this->buildReadme($addon, $path);
$this->buildScreenshots($addon, $package, $path);
}
$addon->LastBuilt = $time;
$addon->write();
}
示例9: 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);
}
示例10: addPackages
/**
* @param array $releases
* @param string $connectPackage
* @return RepositoryInterface
*/
private function addPackages(array $releases, $connectPackage)
{
return new ArrayRepository(array_map(function ($release) use($connectPackage) {
$distUrl = sprintf($this->distUrlFormat, $connectPackage, $release, $connectPackage, $release);
$package = new Package(strtolower($connectPackage), $release, $release);
$package->setDistUrl($distUrl);
$package->setDistType('tar');
$package->setType('magento-module');
$package->setExtra(['package-xml' => "package.xml"]);
return $package;
}, $releases));
}
示例11: addPackages
/**
* @param array $releases
* @param string $connectPackage
* @param VersionParser $versionParser
* @return RepositoryInterface
*/
private function addPackages(array $releases, $connectPackage, VersionParser $versionParser)
{
$releases = array_filter($releases, function ($release) use($versionParser) {
try {
$versionParser->normalize($release);
} catch (UnexpectedValueException $e) {
$this->writeVerbose(sprintf('Version "%s" is not valid. Skipping this version.', $release));
return false;
}
return true;
});
return new ArrayRepository(array_map(function ($release) use($connectPackage, $versionParser) {
$distUrl = sprintf($this->distUrlFormat, $connectPackage, $release, $connectPackage, $release);
$release = $versionParser->normalize($release);
$package = new Package(strtolower($connectPackage), $release, $release);
$package->setDistUrl($distUrl);
$package->setDistType('tar');
$package->setType('magento-module');
$package->setExtra(['package-xml' => "package.xml"]);
return $package;
}, $releases));
}
示例12: 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>");
}
}
}
}
示例13: bindPackageValues
/**
* @param string $newName
* @param array $package
* @return Package
*/
protected static function bindPackageValues($newName, array $package)
{
$new = new Package($newName, $package['version'], $package['version']);
$new->setType('dist');
if (isset($package['bin'])) {
$new->setBinaries($package['bin']);
}
if (isset($package['dist']['type'])) {
$new->setDistType($package['dist']['type']);
}
if (isset($package['dist']['url'])) {
$new->setDistUrl($package['dist']['url']);
}
if (isset($package['excludes'])) {
$new->setArchiveExcludes($package['excludes']);
}
return $new;
}