mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
Migrate to HTMX (#114)
Dropped Livewire Added HTMX Added Blade code lint Drop Mysql and Redis Migrate to SQLite
This commit is contained in:
@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Throwable;
|
||||
@ -13,14 +14,18 @@ class UpdatePHPIni
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(Service $service, string $ini): void
|
||||
public function update(Server $server, array $input): void
|
||||
{
|
||||
$this->validate($server, $input);
|
||||
|
||||
$service = $server->php($input['version']);
|
||||
|
||||
$tmpName = Str::random(10).strtotime('now');
|
||||
try {
|
||||
/** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */
|
||||
$storageDisk = Storage::disk('local');
|
||||
|
||||
$storageDisk->put($tmpName, $ini);
|
||||
$storageDisk->put($tmpName, $input['ini']);
|
||||
$service->server->ssh('root')->upload(
|
||||
$storageDisk->path($tmpName),
|
||||
"/etc/php/$service->version/cli/php.ini"
|
||||
@ -42,4 +47,21 @@ private function deleteTempFile(string $name): void
|
||||
Storage::disk('local')->delete($name);
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(Server $server, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'ini' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
'version' => 'required|string',
|
||||
])->validate();
|
||||
|
||||
if (! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user