Sunday, April 3, 2022

[SOLVED] How To Fix Apache malformed header from script 'index.php': Bad header: Register In Laravel 5.6

Issue

How To Fix Apache malformed header from script 'index.php': Bad header: Register In Laravel 5.6

Run In Apache 2.4.29 (CenOS 7)

Code

href="https://i.stack.imgur.com/pmsFI.png" rel="nofollow noreferrer">enter image description here

Result

enter image description here

Log Apache error_log Show ==>> [Sat Apr 21 22:04:03.967658 2018] [core:error] [pid 18494:tid 139869258323712] [client 27.55.71.124:57216] malformed header from script 'index.php': Bad header: Register Repositories

But Run In Xampp (Local) Run Success

Thank You


Solution

The method ConsoleOutput::writeln writes to the stdout but the headers would not work for a web server, so this doesn't makes sense.

Instead, you should be checking if your application is running in the console when executing this portion of code:

if(app()->runningInConsole()) {
    ConsoleOuput::writeln('Register Repositories');
}


Answered By - Ohgodwhy
Answer Checked By - Senaida (WPSolving Volunteer)