Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fabricecw's avatar

EOL format in blade

Hi

I try to generate a shell script with a blade template. Now, the generateted file always has \r\n line break instead of \n (download it directly with curl on the system)

My response method (removed the variables...):

private function downloadShell($id, $name) {
        $file = Storage::disk('local')->get('shellscripts/shell.sh');

        return (new Response($file))
            ->header('Content-Type', 'text/plain');
    }

Should I work with str_replace or is there a smarter way to convert it for unix? Thanks for your help!

Regards,

0 likes
2 replies
martinbean's avatar

@Contoweb Why are you trying to generate a shell file with Blade, and why are you trying to download shell files?

Blade is a templating language. It has no role doing anything functional such as generating scripts.

fabricecw's avatar

@martinbean I input some parameters via a form and generate a plain text file (contains bash commands). I use blade to fill in the parameters. On a remote server i wan't to download the file manualy and execute it. But at the moment, if I download the generated file, I can't execute it because the line break is \r\n and not \n

Laravel/Blade should only generate the plain text file... Nothing else (at the moment).

Similar to the forge host setup on a custom vps...

Do you know what I mean?

Please or to participate in this conversation.