Skip to content

Commit

Permalink
Merge pull request #132 from genesisweb/php-helper
Browse files Browse the repository at this point in the history
V2 - Changes
  • Loading branch information
uttamrabadiya authored Jun 12, 2024
2 parents 1c4b33a + d4d2516 commit df1348a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 42 deletions.
27 changes: 0 additions & 27 deletions TODO

This file was deleted.

8 changes: 4 additions & 4 deletions cli/Valet/DnsMasq.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function createCustomConfigFile(string $domain): void
{
$this->files->putAsUser(
$this->configPath,
'address=/.'.$domain.'/127.0.0.1'.PHP_EOL.'server=1.1.1.1'.PHP_EOL.'server=8.8.8.8'.PHP_EOL
'address=/.' . $domain . '/127.0.0.1' . PHP_EOL . 'server=1.1.1.1' . PHP_EOL . 'server=8.8.8.8' . PHP_EOL
);
}

Expand Down Expand Up @@ -176,15 +176,15 @@ private function dnsmasqSetup(): void

$this->files->putAsUser(
$this->dnsmasqconf,
$this->files->get(VALET_ROOT_PATH.'/cli/stubs/dnsmasq.conf')
$this->files->get(VALET_ROOT_PATH . '/cli/stubs/dnsmasq.conf')
);
$this->files->putAsUser(
$this->dnsmasqOpts,
$this->files->get(VALET_ROOT_PATH.'/cli/stubs/dnsmasq_options')
$this->files->get(VALET_ROOT_PATH . '/cli/stubs/dnsmasq_options')
);
$this->files->putAsUser(
$this->nmConfigPath,
$this->files->get(VALET_ROOT_PATH.'/cli/stubs/networkmanager.conf')
$this->files->get(VALET_ROOT_PATH . '/cli/stubs/networkmanager.conf')
);
}
}
8 changes: 5 additions & 3 deletions cli/Valet/PackageManagers/Dnf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class Dnf implements PackageManager
/**
* @var array
*/
public const PHP_FPM_PATTERN_BY_VERSION = [];
public const PHP_FPM_PATTERN_BY_VERSION = [
'8.3' => 'php-fpm',
];

private const PACKAGES = [
'redis' => 'redis',
Expand Down Expand Up @@ -67,10 +69,10 @@ public function installOrFail(string $package): void
{
Writer::twoColumnDetail($package, 'Installing');

$this->cli->run(trim('dnf install -y '.$package), function ($exitCode, $errorOutput) use ($package) {
$this->cli->run(trim('dnf install -y ' . $package), function ($exitCode, $errorOutput) use ($package) {
Writer::error(\sprintf('%s: %s', $exitCode, $errorOutput));

throw new DomainException('Dnf was unable to install ['.$package.'].');
throw new DomainException('Dnf was unable to install [' . $package . '].');
});
}

Expand Down
2 changes: 0 additions & 2 deletions cli/Valet/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace Valet;

use ConsoleComponents\Writer;
use Illuminate\Support\Collection;
use Valet\Contracts\PackageManager;
use Valet\Contracts\ServiceManager;
use Valet\Exceptions\VersionException;
use Valet\Facades\DevTools as DevToolsFacade;

class PhpFpm
Expand Down
2 changes: 1 addition & 1 deletion cli/Valet/SiteIsolate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Support\Collection;
use Valet\Contracts\PackageManager;
use Valet\Facades\DevTools as DevToolsFacade;
use Valet\Facades\PhpFpm as PhpFpmFacade;
use Valet\Facades\Nginx as NginxFacade;
use Valet\Facades\PhpFpm as PhpFpmFacade;
use Valet\Traits\Paths;

class SiteIsolate
Expand Down
6 changes: 5 additions & 1 deletion cli/Valet/Valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function migrateConfig(): void
}
}

if ($this->files->exists($oldHomePath . '/valet.sock')) {
PhpFpmFacade::stop();
}

// Copy directory
$this->files->copyDirectory($oldHomePath, $newHomePath);

Expand Down Expand Up @@ -198,7 +202,7 @@ private function updateNginxConfFiles(): void

$nginxConfig = $this->files->get(Nginx::NGINX_CONF);
$nginxConfig = str_replace($oldHomePath, $newHomePath, $nginxConfig);
$this->files->put(Nginx::SITES_AVAILABLE_CONF, $nginxConfig);
$this->files->put(Nginx::NGINX_CONF, $nginxConfig);
}

private function getRunningFpmVersions(string $homePath): array
Expand Down
1 change: 0 additions & 1 deletion cli/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
/**
* Load correct autoloader depending on install location.
*/

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
Expand Down
4 changes: 2 additions & 2 deletions cli/includes/compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
exit(1);
}

if (version_compare(PHP_VERSION, '7.1', '<')) {
echo 'Valet requires PHP 7.1 or later.';
if (version_compare(PHP_VERSION, '8.2', '<')) {
echo 'Valet requires PHP 8.2 or later.';

exit(1);
}
1 change: 0 additions & 1 deletion tests/Unit/PhpFpmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use ConsoleComponents\Writer;
use Mockery;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Output\BufferedOutput;
use Valet\CommandLine;
use Valet\Configuration;
use Valet\Contracts\PackageManager;
Expand Down

0 comments on commit df1348a

Please sign in to comment.