Skip to content

Commit

Permalink
Merge branch 'fix-377'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarcher committed Aug 9, 2023
2 parents 0639238 + 1ed3512 commit b0830ea
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions cli/Valet/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,23 +379,45 @@ public function getVersion($real = false)

return $version;
}

/**
* Get the possible PHP FPM service names.
*
* @return array
*/
public function getFpmServiceNames()
{
return [
"php-fpm",
"php-fpm{$this->version}",
"php{$this->version}-fpm",
];
}

/**
* Determine php service name
*
* @return string
*/
public function fpmServiceName($version = null)
public function fpmServiceName()
{
if (!$version) {
$version = $this->getPhpVersion();
$services = array_map(function ($serviceName) {
return [
'name' => $serviceName,
'status' => $this->sm->status($serviceName),
];
}, $this->getFpmServiceNames());
$services = array_filter($services, function ($service) {
return false === strpos($service['status'], 'not-found') && false === strpos($service['status'], 'not be found');
});
$service = reset($services);
if (is_array($service) && ! empty($service['name'])) {
return $service['name'];
}

return "php{$version}-fpm";

return new DomainException('Unable to determine PHP service name.');
}



/**
* Get FPM sock file name for a given PHP version.
*
Expand Down

0 comments on commit b0830ea

Please sign in to comment.