rap2hpoutre/laravel-log-viewer

Laravel 11 Support

AmmadGetlicensed opened this issue · 3 comments

Please make support for Laravel 11, right now its not compatible.

bump

I have made my own temporary solution, not ideal but works, remember to make it protected by a middleware

    public function showLaravelLogs()
    {
        $deleteAllFiles = \Request::get('delete-all-files') == "true";
        $path = storage_path('logs');
        $files = \File::allFiles($path);

        if (!$deleteAllFiles) {
            echo "<a href='?delete-all-files=true'>Remove all filez<a/>";
        }

        foreach ($files as $file) {
            $actualPath = $path . DIRECTORY_SEPARATOR . $file->getFilename();
            if ($deleteAllFiles) {
                unlink($actualPath);
                continue;
            }
            $path2Display = file_get_contents($actualPath);
            echo "<h1 style='display: block'>{$file->getFilename()}</h1>";
            echo "<div><pre>$path2Display</pre></div>";
        }

        if ($deleteAllFiles) {
            return redirect('/backoffice/logs');
        }

    }

Thank you for your contribution!
I just released an updated version that accepts Laravel 11 (v2.4.0).
Let me know if there is any problem