Installs package.

@param Package $package
15774
protected function requirePackage(Package $package)
    {
        $version = $this->chooseVersion($package);
        passthru(sprintf(
            'composer require %s:%s',
            $package->getName(),
            $version
        ));
        $this->comment('Package ' . $package->getName() . ' installed');
        $versions = $package->getVersions();
        $v = array_get($versions, $version);

        // Run post-process in separate command to load it with new autoloader
        passthru(sprintf(
            'php artisan package:process %s %s',
            $package->getName(),
            base64_encode(serialize($v))
        ));
    }
1088208
protected function define(PackageDefinition $package)
    {
        $package->name('blog');

        $package->metadata([
            'icon' => 'rss',
        ]);

        $package->modules([
            'categories' => BlogCategoryModule::class,
            'authors'    => BlogAuthorModule::class,
            'articles'   => BlogArticleModule::class,
        ]);
    }
732808
public function setPackage($package)
    {
        $this->package = implode('\\', array_map(function ($piece) {
            return Inflector::classify(Inflector::underscore($piece));
        }, explode('.', $package)));
        
        return $this;
    }
569371
public function addPackage($package, $version)
    {
        $config = $this->getContent();
        $config['require'][$package] = $version;
        $this->setContent($config);
    }
488338
public function setPackage($package)
    {
        $parts = explode('/', $package);
        if (count($parts) > 2) {
            throw new BuildException('Invalid package name: ' . $package);
        }

        if (count($parts) == 1) {
            $this->channel = 'pear.php.net';
            $this->package = $parts[0];
        } else {
            $this->channel = $parts[0];
            $this->package = $parts[1];
        }
    }
522170
public function setPackages(array $packages)
    {
        foreach ($packages as $name => $location) {
            if (is_array($location)) {
                if (array_key_exists('name', $location)
                    && array_key_exists('location', $location)) {
                        $name       = $location['name'];
                        $location   = $location['location'];
                    } else {
                        list($name, $location) = $location;
                    }
            }
            $this->addPackage($name, $location);
        }
    }
531370
public function install(PackageWrapper $package, $isDev)
    {
        $args = ['install'];
        if (!$isDev) {
            $args[] = '--production';
        }
        $this->execute('npm', $args, $this->io, $package->getPath());
    }
1133967
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {
        parent::install($repo, $package);
        $instructions = $this->getInstructions($package);
        if (!$instructions || empty($instructions['install'])) { return; }
        $this->handleInstructions($package, $instructions['install']);
    }
205784
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        $this->bootstrap();

        // display info on "composer update" on command line
        echo 'add  ' . $package->getName() . ' to wambo modules';
        echo PHP_EOL;

        $wamboInstallerService = new WamboInstallerService($package);

        $className = $wamboInstallerService->getBootstrapClassName();
        $name = $package->getName();
        $version = $package->getVersion();

        $module = new Module($name, $version, $className);
        $this->moduleRepository->add($module);

        parent::install($repo, $package);
    }
1370129
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        new Textpattern();
        parent::install($repo, $package);
        $plugin = new $this->textpatternPackager($this->getInstallPath($package), $package);
        $plugin->install();
    }
655916
public function execute(array $packages)
    {
        if (empty($packages)) {
            throw new PackageManagerException('No package specified for removal');
        }

        /** @var \Bolt\Filesystem\Handler\JsonFile $jsonFile */
        $jsonFile = $this->getOptions()->composerJson();
        $composerJson = $composerBackup = $jsonFile->parse();
        $type = $this->getOptions()->dev() ? 'require-dev' : 'require';

        // Remove packages from JSON
        foreach ($packages as $package) {
            unset($composerJson[$type][$package]);
        }
        if (empty($composerJson[$type])) {
            unset($composerJson[$type]);
        }
        $jsonFile->dump($composerJson);

        $io = $this->getIO();
        // Reload Composer config
        $composer = $this->resetComposer();
        // Create the installer
        $install = Installer::create($io, $composer)
            ->setVerbose($this->getOptions()->verbose())
            ->setDevMode(!$this->getOptions()->updateNoDev())
            ->setUpdate(true)
            ->setUpdateWhitelist($packages)
            ->setWhitelistDependencies($this->getOptions()->updateWithDependencies())
            ->setIgnorePlatformRequirements($this->getOptions()->ignorePlatformReqs())
            ->setRunScripts(!$this->getOptions()->noScripts())
        ;

        try {
            $status = $install->run();
        } catch (\Exception $e) {
            $msg = sprintf('%s received an error from Composer: %s in %s::%s', __METHOD__, $e->getMessage(), $e->getFile(), $e->getLine());
            $this->app['logger.system']->critical($msg, ['event' => 'exception', 'exception' => $e]);

            throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
        }

        if ($status !== 0) {
            // Write out old JSON file
            $jsonFile->dump($composerBackup);
        } else {
            $jsonFile->dump($composerJson);
        }

        return $status;
    }
1278591
protected function processPackage(Package $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        $this->originalFiles[$package->getPrettyName()] = $files;

        if (is_array($files)) {
            $this->addFiles($package, $files);
        }
        if ($package->isRoot()) {
            $this->loadDotEnv($package);
            if (!empty($extra[self::EXTRA_DEV_OPTION_NAME])) {
                $this->addFiles($package, $extra[self::EXTRA_DEV_OPTION_NAME]);
            }
        }

        $aliases = $package->collectAliases();

        $this->builder->mergeAliases($aliases);
        $this->builder->setPackage($package->getPrettyName(), array_filter([
            'name' => $package->getPrettyName(),
            'version' => $package->getVersion(),
            'reference' => $package->getSourceReference() ?: $package->getDistReference(),
            'aliases' => $aliases,
        ]));
    }
632780
public function remove($package)
    {
        $output = $this->runCommand(self::REMOVE, $package, self::REMOVE_ARGS);

        if (!$output) {
            return true;
        }

        return false;
    }
679475
protected function installEntryFiles(PackageInterface $package)
    {
        foreach ($this->getEntryFileLocations($package) as $src => $dest) {
            $copied = $this->filesystem->copyFile($src, $dest);

            $this->io->notice(
                sprintf(
                    '    <fg=default>Copying <fg=magenta>%1$s</> to <fg=magenta>%2$s</> -</> %3$s',
                    $src,
                    $dest,
                    $copied ? '<fg=green>OK</>' : '<fg=red>FAILED</>'
                )
            );

            if (! $copied) {
                throw new RuntimeException(sprintf('Cannot copy %s to %s', $src, $dest));
            }
        }
    }
1235836
private function loadPackageRuleSet(Package $package)
    {
        $ruleSet = new RuleSet();
        $key = $package->generatePackageKey();

        if ($this->cache->has($key)) {
            $ruleSet = $this->cache->getCachedRuleSet($key);
        } elseif (is_dir($path = $package->getPackagePath(self::PACKAGE_PATH))) {
            $ruleSet = $this->traverser->traverse($path);
            $this->cache->cacheRuleSet($key, $ruleSet);
        } else {
            // there is no vendor package in the given path
        }

        return $ruleSet;
    }
1364989
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        parent::install($repo, $package);

        $this->_installAutoloader($package);
        $this->_copyAssets($package);
    }
739033
public function setPackage($package)
    {
        if ($package === $this->package) {
            return;
        }

        $this->package = $package;
        $this->packageOverridden = false;
    }