Loading public/helloWorld.html 0 → 100644 +10 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> hello World </body> </html> No newline at end of file src/Controller/ReadLogFileController.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?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); } } Loading
public/helloWorld.html 0 → 100644 +10 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> hello World </body> </html> No newline at end of file
src/Controller/ReadLogFileController.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?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); } }