<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class ReadLogFileController extends AbstractController { /** * Принимает путь до файла, * проверяет, что файл существует и выводит пользователю весь контент файла * (файл можешь создать любой) * * @param string $filePath путь до файла * @return Response */ #[Route('/read/{filePath}', name: 'app_read_log_file', methods: ['GET'])] public function index(string $filePath): Response { $fileSystem = new Filesystem(); if (!$fileSystem->exists($filePath)) { return new Response('File not found', Response::HTTP_NOT_FOUND); } return new Response(file_get_contents($filePath), Response::HTTP_OK); } }