laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.22k stars 10.91k forks source link

New Lines is config cause new Lines in api response #52646

Closed CovertError closed 2 weeks ago

CovertError commented 2 weeks ago

Laravel Version

10.48.20

PHP Version

8.2

Database Driver & Version

No response

Description

the issue is if you add any empty lines in any config file you will see those empty lines in the api response for some reason

check this repo

https://github.com/CovertError/LivewireTest

basically there is one api http://livewiretest.test/api/test

if you send a get request you will get a ton of empty lines because there are empty lines in the config file app.php but this is not just for the app.php for any config file

Steps To Reproduce

check this repo

https://github.com/CovertError/LivewireTest

basically there is one api http://livewiretest.test/api/test

if you send a get request you will get a ton of empty lines because there are empty lines in the config file app.php but this is not just for the app.php for any config file

CovertError commented 2 weeks ago

this has nothing to do with livewire just a test project

noefleury commented 2 weeks ago

The explanation is here :

https://github.com/laravel/framework/blob/769f00ba71de3b3cbbb271e9f34a019b584982c9/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php#L96

From PHP manual :

The include expression includes and evaluates the specified file.

So I think it cannot be considered as an issue as you are explicitly manipulating some PHP source files.


Note that it look like it was working this way from years. See L10 and previously (before L11 new slim skeleton): https://github.com/laravel/framework/blame/10.x/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php#L70

CovertError commented 2 weeks ago

I was told by Tylor "That’s how PHP works? Those lines are not within PHP tags and will be sent to the browser" I guess this can be closed