Newer
Older
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
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, ReadLogFileAction $action): Response
try {
return new Response($action->act($filePath));
} catch (\Exception $exception) {
return new Response('Searching file not found :/', 422);