-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning rendered blade component causes file_exists to fail on some systems #32254
Comments
Can you please share the exact code that's causing this? |
src/Illuminate/View/Component.php:64
|
Please share your own code that's causing this. |
Create blade component:
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Foobar extends Component
{
public function render() {
return str_repeat('a', 9999);
}
}
Route::get('/component-test', function(){
return view('component');
});
<h1>Component</h1>
<x-foobar/> Opening
This error only occurs on production server (Ubuntu). On my local dev machine (MacOS) everything works fine, but the problem remains: Laravel calls |
Is there any reason at all why you can't place the contents in a view? |
I am placing it in a view, this is a simplified example. My render function looks more like this: public function render() {
return view('components.foobar')->render();
} I'm doing this for custom caching purposes. Main point still stands - I'm returning a string. Docs make it clear returning either string or a View is fine, but doesn't mention anywhere that string could also be a filepath and not just plain content. |
@raitisg you don't need the render method above. Feel free to pr to the docs if you want to clarify anything. Thanks. |
It was a simplified example. Yes - in this specific scenario it is indeed not needed, but that is beyond the point. My actual code does more and I can not return View - only string. Documentation states: /**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('components.alert');
} Which is not entirely true. Returning contents can throw this error. You can also return view filename which is not mentioned. |
@raitisg it's true that contents can throw this error but in that case you should really just place the contents in a view. |
There is any solution? |
Any solution yet? The content comes from database, so it has to be string, not a view. Tried the |
This is not fixed: the solution merged in #41956 is a bit too optimistic and do not considers the length of paths concatenated to the components' rendered strings (more exactly in A definitive solution may be to test the length of every string in Opinions? |
This is still an issue. |
Description:
When Component class returns string (html),
resolveView()
checks if such file exists before creating view from string. If component's content is large enough, exception is thrown:file_exists(): File name is longer than the maximum allowed path length on this platform (4096): /path/to/html-string-...
Steps To Reproduce:
Create component class:
The text was updated successfully, but these errors were encountered: