本文整理汇总了PHP中Composer\Package\Package::setInstallationSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::setInstallationSource方法的具体用法?PHP Package::setInstallationSource怎么用?PHP Package::setInstallationSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\Package
的用法示例。
在下文中一共展示了Package::setInstallationSource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例5: 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>');
}
示例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: 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>");
}
}
}
}