for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of `Composer as a service`.
*
* (c) Pascal Borreli <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ayaline\Bundle\ComposerBundle\Consumer\Step;
use Sonata\NotificationBundle\Consumer\ConsumerEvent;
use Symfony\Component\Process\Process;
/**
* @author Hubert Moutot <[email protected]>
class ServeVendorStep extends AbstractStep
{
* {@inheritdoc}
public function execute(ConsumerEvent $event, $directory)
$sha1LockFile = sha1_file($this->workingTempPath.'/'.$directory.'/composer.lock');
$resultPath = $this->rootDir.'/../web/assets/'.$sha1LockFile;
if (is_file($resultPath.'/vendor.zip')) {
$this->triggerNewStep($event, ['message' => 'Serving cached vendor.zip']);
return 0;
}
$this->triggerNewStep($event, ['message' => 'Compressing vendor.zip']);
$this->filesystem->mkdir($resultPath);
$process = new Process('zip -rq '.$resultPath.'/vendor.zip .');
$process->setWorkingDirectory($this->workingTempPath.'/'.$directory);
$process->run();
if (!$process->isSuccessful()) {
$this->triggerError($event, ['message' => $process->getErrorOutput()]);
return 1;