mirror of
https://github.com/flarum/framework.git
synced 2025-04-25 22:24:04 +08:00
chore(package-manager): config composer to use web php version
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
parent
f6761843b2
commit
fd196454a5
@ -9,6 +9,7 @@
|
||||
|
||||
namespace Flarum\PackageManager\Composer;
|
||||
|
||||
use Composer\Config;
|
||||
use Composer\Console\Application;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\PackageManager\OutputLogger;
|
||||
@ -70,4 +71,9 @@ class ComposerAdapter
|
||||
|
||||
return new ComposerOutput($exitCode, $output);
|
||||
}
|
||||
|
||||
public static function setPhpVersion(string $phpVersion)
|
||||
{
|
||||
Config::$defaultConfig['platform']['php'] = $phpVersion;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace Flarum\PackageManager\Job;
|
||||
|
||||
use Flarum\Bus\Dispatcher;
|
||||
use Flarum\PackageManager\Command\BusinessCommandInterface;
|
||||
use Flarum\PackageManager\Composer\ComposerAdapter;
|
||||
use Flarum\Queue\AbstractJob;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
use Throwable;
|
||||
@ -23,11 +24,11 @@ class ComposerCommandJob extends AbstractJob
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
* @var string
|
||||
*/
|
||||
protected $phpVersion;
|
||||
|
||||
public function __construct(BusinessCommandInterface $command, array $phpVersion)
|
||||
public function __construct(BusinessCommandInterface $command, string $phpVersion)
|
||||
{
|
||||
$this->command = $command;
|
||||
$this->phpVersion = $phpVersion;
|
||||
@ -36,12 +37,7 @@ class ComposerCommandJob extends AbstractJob
|
||||
public function handle(Dispatcher $bus)
|
||||
{
|
||||
try {
|
||||
if ([PHP_MAJOR_VERSION, PHP_MINOR_VERSION] !== [$this->phpVersion[0], $this->phpVersion[1]]) {
|
||||
$webPhpVersion = implode('.', $this->phpVersion);
|
||||
$sshPhpVersion = implode('.', [PHP_MAJOR_VERSION, PHP_MINOR_VERSION]);
|
||||
|
||||
throw new \Exception("PHP version mismatch. SSH PHP version must match web server PHP version. Found SSH (PHP $sshPhpVersion) and Web Server (PHP $webPhpVersion).");
|
||||
}
|
||||
ComposerAdapter::setPhpVersion($this->phpVersion);
|
||||
|
||||
$this->command->task->start();
|
||||
|
||||
|
@ -73,7 +73,7 @@ class Dispatcher
|
||||
$command->task = $task;
|
||||
|
||||
$this->queue->push(
|
||||
new ComposerCommandJob($command, [PHP_MAJOR_VERSION, PHP_MINOR_VERSION])
|
||||
new ComposerCommandJob($command, PHP_VERSION)
|
||||
);
|
||||
} else {
|
||||
$data = $this->bus->dispatch($command);
|
||||
|
Loading…
x
Reference in New Issue
Block a user