1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

Clean up PhpFPM readability

This commit is contained in:
Matt Stauffer
2022-03-12 22:37:57 -05:00
parent 592354877d
commit 3570c748a0

View File

@@ -79,37 +79,46 @@ public function uninstall()
*/ */
public function createConfigurationFiles($phpVersion = null) public function createConfigurationFiles($phpVersion = null)
{ {
info(sprintf('Updating PHP configuration%s...', $phpVersion ? ' for '.$phpVersion : '')); info(sprintf('Updating PHP configuration%s...', ($phpVersion ? ' for '.$phpVersion : '')));
$fpmConfigFile = $this->fpmConfigPath($phpVersion); $fpmConfigFile = $this->fpmConfigPath($phpVersion);
$this->files->ensureDirExists(dirname($fpmConfigFile), user()); $this->files->ensureDirExists(dirname($fpmConfigFile), user());
// Drop in a valet-specific fpm pool config // Create FPM Config File from stub
$contents = $this->files->get(__DIR__.'/../stubs/etc-phpfpm-valet.conf'); $contents = str_replace(
$contents = str_replace(['VALET_USER', 'VALET_HOME_PATH'], [user(), VALET_HOME_PATH], $contents); ['VALET_USER', 'VALET_HOME_PATH'],
[user(), VALET_HOME_PATH],
$this->files->get(__DIR__.'/../stubs/etc-phpfpm-valet.conf')
);
if ($phpVersion) { if ($phpVersion) {
$contents = str_replace('valet.sock', self::fpmSockName($phpVersion), $contents); $contents = str_replace('valet.sock', self::fpmSockName($phpVersion), $contents);
} }
$this->files->put($fpmConfigFile, $contents); $this->files->put($fpmConfigFile, $contents);
// Set log and ini files // Create other config files from stubs
$destDir = dirname(dirname($fpmConfigFile)).'/conf.d'; $destDir = dirname(dirname($fpmConfigFile)).'/conf.d';
$this->files->ensureDirExists($destDir, user()); $this->files->ensureDirExists($destDir, user());
$contents = $this->files->get(__DIR__.'/../stubs/php-memory-limits.ini'); $this->files->putAsUser(
$this->files->putAsUser($destDir.'/php-memory-limits.ini', $contents); $destDir.'/php-memory-limits.ini',
$this->files->get(__DIR__.'/../stubs/php-memory-limits.ini')
);
$contents = $this->files->get(__DIR__.'/../stubs/etc-phpfpm-error_log.ini'); $contents = str_replace(
$contents = str_replace(['VALET_USER', 'VALET_HOME_PATH'], [user(), VALET_HOME_PATH], $contents); ['VALET_USER', 'VALET_HOME_PATH'],
[user(), VALET_HOME_PATH],
$this->files->get(__DIR__.'/../stubs/etc-phpfpm-error_log.ini')
);
$this->files->putAsUser($destDir.'/error_log.ini', $contents); $this->files->putAsUser($destDir.'/error_log.ini', $contents);
// Create log directory and file
$this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user()); $this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());
$this->files->touch(VALET_HOME_PATH.'/Log/php-fpm.log', user()); $this->files->touch(VALET_HOME_PATH.'/Log/php-fpm.log', user());
} }
/** /**
* Restart the PHP FPM process(es). * Restart the PHP FPM process (if one specified) or processes (if none specified).
* *
* @param string|null $phpVersion * @param string|null $phpVersion
* @return void * @return void
@@ -151,7 +160,7 @@ public function fpmConfigPath($phpVersion = null)
} }
/** /**
* Only stop running php services. * Stop only the running php services.
*/ */
public function stopRunning() public function stopRunning()
{ {
@@ -165,7 +174,7 @@ public function stopRunning()
} }
/** /**
* Stop a given PHP version, if a specific version isn't being used globally or by any sites. * Stop a given PHP version, if that specific version isn't being used globally or by any sites.
* *
* @param string|null $phpVersion * @param string|null $phpVersion
* @return void * @return void