diff --git a/public/helloWorld.html b/public/helloWorld.html new file mode 100644 index 0000000000000000000000000000000000000000..a47038fb4df6084ff76bc7f124a867135c1f0858 --- /dev/null +++ b/public/helloWorld.html @@ -0,0 +1,10 @@ +<!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 diff --git a/src/Controller/ReadLogFileController.php b/src/Controller/ReadLogFileController.php new file mode 100644 index 0000000000000000000000000000000000000000..f62e6a214bbb620b426808af83540eabdc19c3f4 --- /dev/null +++ b/src/Controller/ReadLogFileController.php @@ -0,0 +1,28 @@ +<?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); + } +}