install() public method

public install ( array $install, boolean $packagist = false, boolean $writeConfig = true, boolean $preferSource = false ) : boolean
$install array [name => version, name => version, ...]
$packagist boolean
$writeConfig boolean
$preferSource boolean
return boolean
示例#1
0
 /**
  * @param  array $install
  * @param bool $packagist
  * @param bool $preferSource
  * @return bool
  */
 public function install(array $install = [], $packagist = false, $preferSource = false)
 {
     $this->composer->install($install, $packagist, $preferSource);
     $packages = App::package()->all(null, true);
     foreach ($install as $name => $version) {
         if (isset($packages[$name]) && App::module($packages[$name]->get('module'))) {
             $this->enable($packages[$name]);
         } elseif (isset($packages[$name])) {
             $this->doInstall($packages[$name]);
         }
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $packages = [];
     foreach ((array) $this->argument('packages') as $package) {
         $path = $this->container->get('path.packages') . '/' . $package . '/composer.json';
         if (file_exists($path)) {
             $info = json_decode(file_get_contents($path), true);
         }
         if (isset($info['require']) && is_array($info['require'])) {
             $packages = array_merge($packages, $info['require']);
         }
     }
     $config = [];
     foreach (['path.temp', 'path.cache', 'path.vendor', 'path.artifact', 'path.packages', 'system.api'] as $key) {
         $config[$key] = $this->container->get($key);
     }
     $composer = new Composer($config, $output);
     $composer->install($packages, true, false, $this->option('prefer-source'));
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $this->container->path();
     $vers = $this->container->version();
     $filter = '/' . implode('|', $this->excludes) . '/i';
     $packages = ['pagekit/blog' => '*', 'pagekit/theme-one' => '*'];
     $config = [];
     foreach (['path.temp', 'path.cache', 'path.vendor', 'path.artifact', 'path.packages', 'system.api'] as $key) {
         $config[$key] = $this->container->get($key);
     }
     $composer = new Composer($config, $output);
     $composer->install($packages);
     $this->line(sprintf('Starting: webpack'));
     exec('webpack -p');
     $this->line(sprintf('Building Package.'));
     $finder = Finder::create()->files()->in($path)->ignoreVCS(true)->filter(function ($file) use($filter) {
         return !preg_match($filter, $file->getRelativePathname());
     });
     $zip = new \ZipArchive();
     if (true !== $zip->open($zipFile = "{$path}/pagekit-{$vers}.zip", \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
         $this->abort("Can't open ZIP extension in '{$zipFile}'");
     }
     foreach ($finder as $file) {
         $zip->addFile($file->getPathname(), $file->getRelativePathname());
     }
     $zip->addFile("{$path}/.bowerrc", '.bowerrc');
     $zip->addFile("{$path}/.htaccess", '.htaccess');
     $zip->addEmptyDir('tmp/');
     $zip->addEmptyDir('tmp/cache');
     $zip->addEmptyDir('tmp/temp');
     $zip->addEmptyDir('tmp/logs');
     $zip->addEmptyDir('tmp/sessions');
     $zip->addEmptyDir('tmp/packages');
     $zip->close();
     $name = basename($zipFile);
     $size = filesize($zipFile) / 1024 / 1024;
     $this->line(sprintf('Build: %s (%.2f MB)', $name, $size));
 }