mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 16:10:08 +01:00
Drop PHP 5.6; extract site-specific PHP version isolation to its own commands
This commit is contained in:
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [5.6, '7.0', 7.1, 7.2, 7.3, 7.4, '8.0', 8.1]
|
||||
php: ['7.0', 7.1, 7.2, 7.3, 7.4, '8.0', 8.1]
|
||||
|
||||
name: PHP ${{ matrix.php }}
|
||||
|
||||
|
||||
@@ -15,12 +15,10 @@ class Brew
|
||||
'php@7.2',
|
||||
'php@7.1',
|
||||
'php@7.0',
|
||||
'php@5.6',
|
||||
'php73',
|
||||
'php72',
|
||||
'php71',
|
||||
'php70',
|
||||
'php56',
|
||||
];
|
||||
|
||||
const LATEST_PHP_VERSION = 'php@8.1';
|
||||
|
||||
@@ -52,7 +52,7 @@ public function install()
|
||||
|
||||
$this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());
|
||||
|
||||
$this->updateConfiguration();
|
||||
$this->createConfigurationFiles();
|
||||
|
||||
$this->restart();
|
||||
}
|
||||
@@ -70,12 +70,13 @@ public function uninstall()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PHP FPM configuration.
|
||||
* Create (or re-create) the PHP FPM configuration files.
|
||||
* Writes FPM config file, pointing to the correct .sock file, and log and ini files
|
||||
*
|
||||
* @param string|null $phpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function updateConfiguration($phpVersion = null)
|
||||
public function createConfigurationFiles($phpVersion = null)
|
||||
{
|
||||
info(sprintf('Updating PHP configuration%s...', $phpVersion ? ' for '.$phpVersion : ''));
|
||||
|
||||
@@ -83,53 +84,31 @@ public function updateConfiguration($phpVersion = null)
|
||||
|
||||
$this->files->ensureDirExists(dirname($fpmConfigFile), user());
|
||||
|
||||
// rename (to disable) old FPM Pool configuration, regardless of whether it's a default config or one customized by an older Valet version
|
||||
$oldFile = dirname($fpmConfigFile).'/www.conf';
|
||||
if (file_exists($oldFile)) {
|
||||
rename($oldFile, $oldFile.'-backup');
|
||||
}
|
||||
|
||||
if (false === strpos($fpmConfigFile, '5.6')) {
|
||||
// since PHP 7 we can simply drop in a valet-specific fpm pool config, and not touch the default config
|
||||
// Drop in a valet-specific fpm pool config
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/etc-phpfpm-valet.conf');
|
||||
$contents = str_replace(['VALET_USER', 'VALET_HOME_PATH'], [user(), VALET_HOME_PATH], $contents);
|
||||
} else {
|
||||
// for PHP 5 we must do a direct edit of the fpm pool config to switch it to Valet's needs
|
||||
$contents = $this->files->get($fpmConfigFile);
|
||||
$contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents);
|
||||
$contents = preg_replace('/^group = .+$/m', 'group = staff', $contents);
|
||||
$contents = preg_replace('/^listen = .+$/m', 'listen = '.VALET_HOME_PATH.'/valet.sock', $contents);
|
||||
$contents = preg_replace('/^;?listen\.owner = .+$/m', 'listen.owner = '.user(), $contents);
|
||||
$contents = preg_replace('/^;?listen\.group = .+$/m', 'listen.group = staff', $contents);
|
||||
$contents = preg_replace('/^;?listen\.mode = .+$/m', 'listen.mode = 0777', $contents);
|
||||
}
|
||||
|
||||
if ($phpVersion) {
|
||||
$contents = str_replace('valet.sock', $this->fpmSockName($phpVersion), $contents);
|
||||
}
|
||||
|
||||
$this->files->put($fpmConfigFile, $contents);
|
||||
|
||||
// Set log and ini files
|
||||
$destDir = dirname(dirname($fpmConfigFile)) . '/conf.d';
|
||||
$this->files->ensureDirExists($destDir, user());
|
||||
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/php-memory-limits.ini');
|
||||
$destFile = dirname($fpmConfigFile);
|
||||
$destFile = str_replace('/php-fpm.d', '', $destFile);
|
||||
$destFile .= '/conf.d/php-memory-limits.ini';
|
||||
$this->files->ensureDirExists(dirname($destFile), user());
|
||||
$this->files->putAsUser($destFile, $contents);
|
||||
$this->files->putAsUser($destDir.'/php-memory-limits.ini', $contents);
|
||||
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/etc-phpfpm-error_log.ini');
|
||||
$contents = str_replace(['VALET_USER', 'VALET_HOME_PATH'], [user(), VALET_HOME_PATH], $contents);
|
||||
$destFile = dirname($fpmConfigFile);
|
||||
$destFile = str_replace('/php-fpm.d', '', $destFile);
|
||||
$destFile .= '/conf.d/error_log.ini';
|
||||
$this->files->ensureDirExists(dirname($destFile), user());
|
||||
$this->files->putAsUser($destFile, $contents);
|
||||
$this->files->putAsUser($destDir.'/error_log.ini', $contents);
|
||||
|
||||
$this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());
|
||||
$this->files->touch(VALET_HOME_PATH.'/Log/php-fpm.log', user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart the PHP FPM process.
|
||||
* Restart the PHP FPM process(es).
|
||||
*
|
||||
* @param string|null $phpVersion
|
||||
* @return void
|
||||
@@ -167,9 +146,7 @@ public function fpmConfigPath($phpVersion = null)
|
||||
$versionNormalized = $this->normalizePhpVersion($phpVersion === 'php' ? Brew::LATEST_PHP_VERSION : $phpVersion);
|
||||
$versionNormalized = preg_replace('~[^\d\.]~', '', $versionNormalized);
|
||||
|
||||
return $versionNormalized === '5.6'
|
||||
? BREW_PREFIX.'/etc/php/5.6/php-fpm.conf'
|
||||
: BREW_PREFIX."/etc/php/${versionNormalized}/php-fpm.d/valet-fpm.conf";
|
||||
return BREW_PREFIX."/etc/php/${versionNormalized}/php-fpm.d/valet-fpm.conf";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,21 +164,17 @@ public function stopRunning()
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop PHP, if a specific version isn't being used globally or by any sites.
|
||||
* Stop a given PHP version, if a specific version isn't being used globally or by any sites.
|
||||
*
|
||||
* @param string|null $phpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function stopIfUnused($phpVersion)
|
||||
public function stopIfUnused($phpVersion = null)
|
||||
{
|
||||
if (! $phpVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($phpVersion, 'php') === false) {
|
||||
$phpVersion = 'php'.$phpVersion;
|
||||
}
|
||||
|
||||
$phpVersion = $this->normalizePhpVersion($phpVersion);
|
||||
|
||||
if (! in_array($phpVersion, $this->utilizedPhpVersions())) {
|
||||
@@ -210,16 +183,40 @@ public function stopIfUnused($phpVersion)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a specific version of php.
|
||||
* Isolate a given directory to use a specific version of php.
|
||||
*
|
||||
* @param string $directory
|
||||
* @param string $version
|
||||
* @param bool $force
|
||||
* @param string|null $directory
|
||||
* @return string|void
|
||||
* @return void
|
||||
*/
|
||||
public function useVersion($version, $force = false, $directory = null)
|
||||
public function isolateDirectoryToVersion($directory, $version)
|
||||
{
|
||||
if (!$site = $this->site->getSiteUrl($directory)) {
|
||||
throw new DomainException("The [{$directory}] site could not be found in Valet's site list.");
|
||||
}
|
||||
|
||||
$this->brew->ensureInstalled($version, [], $this->taps);
|
||||
|
||||
$oldCustomPhpVersion = $this->site->customPhpVersion($site); // Example output: "74"
|
||||
$this->createConfigurationFiles($version);
|
||||
|
||||
$this->site->isolate($site, $this->fpmSockName($version), $version);
|
||||
|
||||
$this->stopIfUnused($oldCustomPhpVersion);
|
||||
$this->restart($version);
|
||||
$this->nginx->restart();
|
||||
|
||||
info(sprintf('The site [%s] is now using %s.', $site, $version));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove PHP version isolation for a given directory
|
||||
*
|
||||
* @param string $directory
|
||||
* @return void
|
||||
*/
|
||||
public function unIsolateDirectory($directory)
|
||||
{
|
||||
if ($directory) {
|
||||
$site = $this->site->getSiteUrl($directory);
|
||||
|
||||
if (!$site) {
|
||||
@@ -231,17 +228,24 @@ public function useVersion($version, $force = false, $directory = null)
|
||||
);
|
||||
}
|
||||
|
||||
if ($version == 'default') { // Remove isolation for this site
|
||||
$oldCustomPhpVersion = $this->site->customPhpVersion($site); // Example output: "74"
|
||||
|
||||
$this->site->removeIsolation($site);
|
||||
$this->stopIfUnused($oldCustomPhpVersion);
|
||||
$this->nginx->restart();
|
||||
|
||||
info(sprintf('The site [%s] is now using the default PHP version.', $site));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a specific version of PHP globally.
|
||||
*
|
||||
* @param string $version
|
||||
* @param bool $force
|
||||
* @return string|void
|
||||
*/
|
||||
public function useVersion($version, $force = false)
|
||||
{
|
||||
$version = $this->validateRequestedVersion($version);
|
||||
|
||||
try {
|
||||
@@ -253,31 +257,14 @@ public function useVersion($version, $force = false, $directory = null)
|
||||
} catch (DomainException $e) { /* ignore thrown exception when no linked php is found */
|
||||
}
|
||||
|
||||
if (! $this->brew->installed($version)) {
|
||||
// Install the relevant formula if not already installed
|
||||
$this->brew->ensureInstalled($version, [], $this->taps);
|
||||
}
|
||||
|
||||
if ($directory) {
|
||||
$oldCustomPhpVersion = $this->site->customPhpVersion($site); // Example output: "74"
|
||||
$this->cli->quietly('sudo rm '.VALET_HOME_PATH.'/'.$this->fpmSockName($version));
|
||||
$this->updateConfiguration($version);
|
||||
$this->site->installSiteConfig($site, $this->fpmSockName($version), $version);
|
||||
|
||||
$this->stopIfUnused($oldCustomPhpVersion);
|
||||
$this->restart($version);
|
||||
$this->nginx->restart();
|
||||
info(sprintf('The site [%s] is now using %s.', $site, $version));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Unlink the current global PHP if there is one installed
|
||||
if ($this->brew->hasLinkedPhp()) {
|
||||
$linkedPhp = $this->brew->linkedPhp();
|
||||
|
||||
// Update the old FPM to keep running, using a custom sock file, so existing isolated sites aren't broken
|
||||
$this->updateConfiguration($linkedPhp);
|
||||
$this->createConfigurationFiles($linkedPhp);
|
||||
|
||||
// Update existing custom Nginx config files; if they're using the old or new PHP version,
|
||||
// update them to the new correct sock file location
|
||||
@@ -297,7 +284,6 @@ public function useVersion($version, $force = false, $directory = null)
|
||||
$this->files->unlink(VALET_HOME_PATH.'/valet.sock');
|
||||
$this->cli->quietly('sudo rm '.VALET_HOME_PATH.'/valet*.sock');
|
||||
|
||||
// ensure configuration is correct and start the linked version
|
||||
$this->install();
|
||||
|
||||
$newVersion = $version === 'php' ? $this->brew->determineAliasedVersion($version) : $version;
|
||||
@@ -311,17 +297,22 @@ public function useVersion($version, $force = false, $directory = null)
|
||||
}
|
||||
|
||||
/**
|
||||
* If passed php7.4 or php74 formats, normalize to php@7.4 format.
|
||||
* If passed php7.4, or php74, 7.4, or 74 formats, normalize to php@7.4 format.
|
||||
*/
|
||||
public function normalizePhpVersion($version)
|
||||
{
|
||||
// @todo There's probably a way to incorporate this into the regex
|
||||
if (strpos($version, 'php') === false) {
|
||||
$version = 'php' . $version;
|
||||
}
|
||||
|
||||
return preg_replace('/(php)([0-9+])(?:.)?([0-9+])/i', '$1@$2.$3', $version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the requested version to be sure we can support it.
|
||||
*
|
||||
* @param $version
|
||||
* @param string $version
|
||||
* @return string
|
||||
*/
|
||||
public function validateRequestedVersion($version)
|
||||
@@ -329,12 +320,7 @@ public function validateRequestedVersion($version)
|
||||
$version = $this->normalizePhpVersion($version);
|
||||
|
||||
if (! $this->brew->supportedPhpVersions()->contains($version)) {
|
||||
throw new DomainException(
|
||||
sprintf(
|
||||
'Valet doesn\'t support PHP version: %s (try something like \'php@7.3\' instead)',
|
||||
$version
|
||||
)
|
||||
);
|
||||
throw new DomainException("Valet doesn't support PHP version: {$version} (try something like 'php@7.3' instead)");
|
||||
}
|
||||
|
||||
if (strpos($aliasedVersion = $this->brew->determineAliasedVersion($version), '@')) {
|
||||
@@ -342,10 +328,6 @@ public function validateRequestedVersion($version)
|
||||
}
|
||||
|
||||
if ($version === 'php') {
|
||||
if (strpos($aliasedVersion = $this->brew->determineAliasedVersion($version), '@')) {
|
||||
return $aliasedVersion;
|
||||
}
|
||||
|
||||
if ($this->brew->hasInstalledPhp()) {
|
||||
throw new DomainException('Brew is already using PHP '.PHP_VERSION.' as \'php\' in Homebrew. To use another version, please specify. eg: php@7.3');
|
||||
}
|
||||
|
||||
@@ -704,9 +704,10 @@ public function buildSecureNginxServer($url, $siteConf = null)
|
||||
* @param string $phpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function installSiteConfig($valetSite, $fpmSockName, $phpVersion)
|
||||
public function isolate($valetSite, $fpmSockName, $phpVersion)
|
||||
{
|
||||
if ($this->files->exists($this->nginxPath($valetSite))) {
|
||||
// Modify the existing config if it exists (likely because it's secured)
|
||||
$siteConf = $this->files->get($this->nginxPath($valetSite));
|
||||
$siteConf = $this->replaceSockFile($siteConf, $fpmSockName, $phpVersion);
|
||||
} else {
|
||||
@@ -768,7 +769,7 @@ public function unsecure($url)
|
||||
|
||||
// If the user had isolated the PHP version for this site, swap out .sock file
|
||||
if ($phpVersion) {
|
||||
$this->installSiteConfig($url, "valet{$phpVersion}.sock", $phpVersion);
|
||||
$this->isolate($url, "valet{$phpVersion}.sock", $phpVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||
echo 'Valet requires PHP 5.6 or later.';
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
echo 'Valet requires PHP 7.0 or later.';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -498,14 +498,14 @@
|
||||
$path = getcwd().'/.valetphprc';
|
||||
$linkedVersion = Brew::linkedPhp();
|
||||
if (! file_exists($path)) {
|
||||
return info(sprintf('Valet is using %s.', $linkedVersion));
|
||||
return info("Valet is using {$linkedVersion}.");
|
||||
}
|
||||
|
||||
$phpVersion = trim(file_get_contents($path));
|
||||
info('Found \''.$path.'\' specifying version: '.$phpVersion);
|
||||
info("Found '{$path}' specifying version: {$phpVersion}");
|
||||
|
||||
if ($linkedVersion == $phpVersion) {
|
||||
return info(sprintf('Valet is already using %s.', $linkedVersion));
|
||||
return info("Valet is already using {$linkedVersion}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,6 +515,25 @@
|
||||
'--site' => 'Isolate PHP version of a specific valet site. e.g: --site=site.test',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Allow the user to change the version of php valet uses to serve a given site.
|
||||
*/
|
||||
$app->command('isolate [site] [phpVersion] ', function ($site, $phpVersion) {
|
||||
PhpFpm::isolateDirectoryToVersion($site, $phpVersion);
|
||||
})->descriptions('Change the version of PHP used by valet to serve a given site', [
|
||||
'site' => 'The valet site (e.g. site.test) you want to isolate to a given PHP version',
|
||||
'phpVersion' => 'The PHP version you want to use, e.g php@7.3',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Allow the user to un-do specifying the version of php valet uses to serve a given site.
|
||||
*/
|
||||
$app->command('unisolate [site] ', function ($site) {
|
||||
PhpFpm::unIsolateDirectory($site);
|
||||
})->descriptions('Stop customizing the version of PHP used by valet to serve a given site', [
|
||||
'site' => 'The valet site (e.g. site.test) you want to un-isolate',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tail log file.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6|^7.0|^8.0",
|
||||
"php": "^7.0|^8.0",
|
||||
"illuminate/container": "~5.1|^6.0|^7.0|^8.0|^9.0",
|
||||
"mnapoli/silly": "^1.0",
|
||||
"symfony/process": "^3.0|^4.0|^5.0|^6.0",
|
||||
|
||||
@@ -93,24 +93,16 @@ public function test_has_installed_php_indicates_if_php_is_installed_via_brew()
|
||||
$brew = Mockery::mock(Brew::class.'[installedPhpFormulae]', [new CommandLine, new Filesystem]);
|
||||
$brew->shouldReceive('installedPhpFormulae')->andReturn(collect(['php@7.0']));
|
||||
$this->assertTrue($brew->hasInstalledPhp());
|
||||
|
||||
$brew = Mockery::mock(Brew::class.'[installedPhpFormulae]', [new CommandLine, new Filesystem]);
|
||||
$brew->shouldReceive('installedPhpFormulae')->andReturn(collect(['php@5.6']));
|
||||
$this->assertTrue($brew->hasInstalledPhp());
|
||||
|
||||
$brew = Mockery::mock(Brew::class.'[installedPhpFormulae]', [new CommandLine, new Filesystem]);
|
||||
$brew->shouldReceive('installedPhpFormulae')->andReturn(collect(['php56']));
|
||||
$this->assertTrue($brew->hasInstalledPhp());
|
||||
}
|
||||
|
||||
public function test_tap_taps_the_given_homebrew_repository()
|
||||
{
|
||||
$cli = Mockery::mock(CommandLine::class);
|
||||
$cli->shouldReceive('passthru')->once()->with('sudo -u "'.user().'" brew tap php@8.0');
|
||||
$cli->shouldReceive('passthru')->once()->with('sudo -u "'.user().'" brew tap php@7.1');
|
||||
$cli->shouldReceive('passthru')->once()->with('sudo -u "'.user().'" brew tap php@7.0');
|
||||
$cli->shouldReceive('passthru')->once()->with('sudo -u "'.user().'" brew tap php@5.6');
|
||||
swap(CommandLine::class, $cli);
|
||||
resolve(Brew::class)->tap('php@7.1', 'php@7.0', 'php@5.6');
|
||||
resolve(Brew::class)->tap('php@8.0', 'php@7.1', 'php@7.0');
|
||||
}
|
||||
|
||||
public function test_restart_restarts_the_service_using_homebrew_services()
|
||||
@@ -163,9 +155,6 @@ public function test_linked_php_returns_linked_php_formula_name()
|
||||
$files->shouldReceive('readLink')->once()->with(BREW_PREFIX.'/bin/php')->andReturn('/test/path/php72/7.2.9_2/test');
|
||||
$this->assertSame('php@7.2', $getBrewMock($files)->linkedPhp());
|
||||
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
$files->shouldReceive('readLink')->once()->with(BREW_PREFIX.'/bin/php')->andReturn('/test/path/php56/test');
|
||||
$this->assertSame('php@5.6', $getBrewMock($files)->linkedPhp());
|
||||
}
|
||||
|
||||
public function test_linked_php_throws_exception_if_no_php_link()
|
||||
@@ -460,15 +449,15 @@ public function supportedPhpLinkPathProvider()
|
||||
'php74',
|
||||
],
|
||||
[
|
||||
'/test/path/php56/test',
|
||||
'/test/path/php71/test',
|
||||
[
|
||||
'path/php56/test',
|
||||
'path/php71/test',
|
||||
'php',
|
||||
'56',
|
||||
'71',
|
||||
'',
|
||||
'',
|
||||
],
|
||||
'php56',
|
||||
'php71',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ public function test_fpm_is_configured_with_the_correct_user_group_and_port()
|
||||
copy(__DIR__.'/files/fpm.conf', __DIR__.'/output/fpm.conf');
|
||||
mkdir(__DIR__.'/output/conf.d');
|
||||
copy(__DIR__.'/files/php-memory-limits.ini', __DIR__.'/output/conf.d/php-memory-limits.ini');
|
||||
resolve(StubForUpdatingFpmConfigFiles::class)->updateConfiguration();
|
||||
resolve(StubForUpdatingFpmConfigFiles::class)->createConfigurationFiles();
|
||||
$contents = file_get_contents(__DIR__.'/output/fpm.conf');
|
||||
$this->assertStringContainsString(sprintf("\nuser = %s", user()), $contents);
|
||||
$this->assertStringContainsString("\ngroup = staff", $contents);
|
||||
$this->assertStringContainsString("\nlisten = ".VALET_HOME_PATH.'/valet.sock', $contents);
|
||||
|
||||
// Passing specific version will change the .sock file
|
||||
resolve(StubForUpdatingFpmConfigFiles::class)->updateConfiguration('php@7.2');
|
||||
resolve(StubForUpdatingFpmConfigFiles::class)->createConfigurationFiles('php@7.2');
|
||||
$contents = file_get_contents(__DIR__.'/output/fpm.conf');
|
||||
$this->assertStringContainsString(sprintf("\nuser = %s", user()), $contents);
|
||||
$this->assertStringContainsString("\ngroup = staff", $contents);
|
||||
@@ -229,7 +229,7 @@ public function test_stopRunning_will_pass_filtered_result_of_getRunningServices
|
||||
->andReturn(collect([
|
||||
'php7.2',
|
||||
'php@7.3',
|
||||
'php56',
|
||||
'php71',
|
||||
'php',
|
||||
'nginx',
|
||||
'somethingelse',
|
||||
@@ -237,7 +237,7 @@ public function test_stopRunning_will_pass_filtered_result_of_getRunningServices
|
||||
$brewMock->shouldReceive('stopService')->once()->with([
|
||||
'php7.2',
|
||||
'php@7.3',
|
||||
'php56',
|
||||
'php71',
|
||||
'php',
|
||||
]);
|
||||
|
||||
@@ -264,7 +264,7 @@ public function test_use_version_will_convert_passed_php_version()
|
||||
|
||||
$brewMock->shouldReceive('supportedPhpVersions')->twice()->andReturn(collect([
|
||||
'php@7.2',
|
||||
'php@5.6',
|
||||
'php@7.1',
|
||||
]));
|
||||
$brewMock->shouldReceive('hasLinkedPhp')->andReturn(false);
|
||||
$brewMock->shouldReceive('ensureInstalled')->with('php@7.2', [], $phpFpmMock->taps);
|
||||
@@ -318,12 +318,12 @@ public function test_use_version_if_already_linked_php_will_unlink_before_instal
|
||||
$cliMock->shouldReceive('quietly')->with('sudo rm '.VALET_HOME_PATH.'/valet*.sock')->once();
|
||||
$fileSystemMock->shouldReceive('unlink')->with(VALET_HOME_PATH.'/valet.sock')->once();
|
||||
|
||||
$phpFpmMock->shouldReceive('updateConfiguration')->with('php@7.1')->once();
|
||||
$phpFpmMock->shouldReceive('createConfigurationFiles')->with('php@7.1')->once();
|
||||
$phpFpmMock->shouldReceive('updateConfigurationForGlobalUpdate')->withArgs(['php@7.2', 'php@7.1'])->once();
|
||||
|
||||
$brewMock->shouldReceive('supportedPhpVersions')->andReturn(collect([
|
||||
'php@7.2',
|
||||
'php@5.6',
|
||||
'php@7.1',
|
||||
]));
|
||||
|
||||
$brewMock->shouldReceive('hasLinkedPhp')->andReturn(true);
|
||||
@@ -343,7 +343,7 @@ public function test_use_version_if_already_linked_php_will_unlink_before_instal
|
||||
$this->assertSame('php@7.2', $phpFpmMock->useVersion('php@7.2'));
|
||||
}
|
||||
|
||||
public function test_use_version_with_site_parameter_will_isolate_a_site()
|
||||
public function test_isolate_will_isolate_a_site()
|
||||
{
|
||||
$brewMock = Mockery::mock(Brew::class);
|
||||
$nginxMock = Mockery::mock(Nginx::class);
|
||||
@@ -360,20 +360,20 @@ public function test_use_version_with_site_parameter_will_isolate_a_site()
|
||||
|
||||
$brewMock->shouldReceive('supportedPhpVersions')->andReturn(collect([
|
||||
'php@7.2',
|
||||
'php@5.6',
|
||||
'php@7.1',
|
||||
]));
|
||||
|
||||
$brewMock->shouldReceive('ensureInstalled')->with('php@7.2', [], $phpFpmMock->taps);
|
||||
$brewMock->shouldReceive('installed')->with('php@7.2');
|
||||
$brewMock->shouldReceive('determineAliasedVersion')->with('php@7.2')->andReturn('php@7.2');
|
||||
$brewMock->shouldReceive('linkedPhp')->once();
|
||||
// $brewMock->shouldReceive('linkedPhp')->once();
|
||||
|
||||
$siteMock->shouldReceive('getSiteUrl')->with('test')->andReturn('test.test');
|
||||
$siteMock->shouldReceive('installSiteConfig')->withArgs(['test.test', 'valet72.sock', 'php@7.2']);
|
||||
$siteMock->shouldReceive('isolate')->withArgs(['test.test', 'valet72.sock', 'php@7.2']);
|
||||
$siteMock->shouldReceive('customPhpVersion')->with('test.test')->andReturn('72');
|
||||
|
||||
$phpFpmMock->shouldReceive('stopIfUnused')->with('72')->once();
|
||||
$phpFpmMock->shouldReceive('updateConfiguration')->with('php@7.2')->once();
|
||||
$phpFpmMock->shouldReceive('createConfigurationFiles')->with('php@7.2')->once();
|
||||
$phpFpmMock->shouldReceive('restart')->with('php@7.2')->once();
|
||||
|
||||
$nginxMock->shouldReceive('restart');
|
||||
@@ -386,10 +386,10 @@ public function test_use_version_with_site_parameter_will_isolate_a_site()
|
||||
$phpFpmMock->shouldNotReceive('install');
|
||||
$phpFpmMock->shouldNotReceive('updateConfigurationForGlobalUpdate');
|
||||
|
||||
$this->assertSame(null, $phpFpmMock->useVersion('php@7.2', false, 'test'));
|
||||
$this->assertSame(null, $phpFpmMock->isolateDirectoryToVersion('test', 'php@7.2'));
|
||||
}
|
||||
|
||||
public function test_use_version_can_remove_isolation_for_a_site()
|
||||
public function test_un_isolate_can_remove_isolation_for_a_site()
|
||||
{
|
||||
$nginxMock = Mockery::mock(Nginx::class);
|
||||
$siteMock = Mockery::mock(Site::class);
|
||||
@@ -409,10 +409,10 @@ public function test_use_version_can_remove_isolation_for_a_site()
|
||||
$phpFpmMock->shouldReceive('stopIfUnused')->with('74');
|
||||
$nginxMock->shouldReceive('restart');
|
||||
|
||||
$this->assertSame(null, $phpFpmMock->useVersion('default', false, 'test'));
|
||||
$this->assertSame(null, $phpFpmMock->unIsolateDirectory('test'));
|
||||
}
|
||||
|
||||
public function test_use_version_will_throw_if_site_is_not_parked_or_linked()
|
||||
public function test_isolate_will_throw_if_site_is_not_parked_or_linked()
|
||||
{
|
||||
$siteMock = Mockery::mock(Site::class);
|
||||
|
||||
@@ -430,7 +430,7 @@ public function test_use_version_will_throw_if_site_is_not_parked_or_linked()
|
||||
|
||||
$siteMock->shouldReceive('getSiteUrl');
|
||||
|
||||
$this->assertSame(null, $phpFpmMock->useVersion('default', false, 'test'));
|
||||
$this->assertSame(null, $phpFpmMock->isolateDirectoryToVersion('test', 'php@8.1'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -630,12 +630,12 @@ public function test_isolation_will_persist_when_removing_ssl_certificate()
|
||||
|
||||
// If a site has an isolated PHP version, there should still be a custom nginx site config
|
||||
$siteMock->shouldReceive('customPhpVersion')->with('site1.test')->andReturn('73')->once();
|
||||
$siteMock->shouldReceive('installSiteConfig')->withArgs(['site1.test', 'valet73.sock', '73'])->once();
|
||||
$siteMock->shouldReceive('isolate')->withArgs(['site1.test', 'valet73.sock', '73'])->once();
|
||||
resolve(Site::class)->unsecure('site1.test');
|
||||
|
||||
// If a site doesn't have an isolated PHP version, there should no longer be a custom nginx site config
|
||||
$siteMock->shouldReceive('customPhpVersion')->with('site2.test')->andReturn(null)->once();
|
||||
$siteMock->shouldNotReceive('installSiteConfig');
|
||||
$siteMock->shouldNotReceive('isolate');
|
||||
resolve(Site::class)->unsecure('site2.test');
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ public function test_can_install_nginx_site_config_for_specific_php_version()
|
||||
'# Valet isolated PHP version : php@8.0'.PHP_EOL.'server { fastcgi_pass: valet80.sock }',
|
||||
]);
|
||||
|
||||
$siteMock->installSiteConfig('site1.test', 'valet80.sock', 'php@8.0');
|
||||
$siteMock->isolate('site1.test', 'valet80.sock', 'php@8.0');
|
||||
|
||||
// When no Nginx file exists, it will create a new config file from the template
|
||||
$files->shouldReceive('exists')->once()->with($siteMock->nginxPath('site2.test'))->andReturn(false);
|
||||
@@ -688,7 +688,7 @@ public function test_can_install_nginx_site_config_for_specific_php_version()
|
||||
}),
|
||||
]);
|
||||
|
||||
$siteMock->installSiteConfig('site2.test', 'valet80.sock', 'php@8.0');
|
||||
$siteMock->isolate('site2.test', 'valet80.sock', 'php@8.0');
|
||||
}
|
||||
|
||||
public function test_it_removes_isolation()
|
||||
|
||||
5
tests/conf.d/error_log.ini
Normal file
5
tests/conf.d/error_log.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
; php-fpm error logging directives
|
||||
|
||||
error_log="/Users/mattstauffer/.config/valet/Log/php-fpm.log"
|
||||
log_errors=on
|
||||
log_level=debug
|
||||
10
tests/conf.d/php-memory-limits.ini
Normal file
10
tests/conf.d/php-memory-limits.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
; Max memory per instance
|
||||
memory_limit = 512M
|
||||
|
||||
;The maximum size of an uploaded file.
|
||||
upload_max_filesize = 512M
|
||||
|
||||
; Sets max size of post data allowed.
|
||||
; Changes to this will also need to be reflected in Nginx with client_max_body_size
|
||||
; This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
|
||||
post_max_size = 512M
|
||||
Reference in New Issue
Block a user