Edmond Tamas Edmond Tamas - 3 months ago 31
PHP Question

Laravel @include into master layout results in: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

I am trying to include into my master.blade.php a top.blade.php file, but I end up with this error:


PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 16384 bytes) in
/Websites/Hermann_Sofa/html/vendor/laravel/framework/src/Illuminate/View/Factory.php
on line 534


Maybe I am doing something wrong?
Thanks!

route.php:

Route::get('/', function () {
return view('home');
});


home.blade.php:

<!-- Stored in resources/views/ -->

@extends('layouts.master')

@section('content')
<p>This is my body content.</p>
@stop


top.blade.php:

<!-- Stored in resources/views/ -->

@extends('layouts.master')

@section('top')
<div class="right col-md-4 pull-right">
<span class="phone"><span class="glyphicon glyphicon-earphone"></span> 0743 443.566</span>
<span class="text-right" data-toggle="modal" data-target="#loginModal"><span class="fa fa-shopping-cart"></span>COSUL</span>
</div>
<div class="left col-md-8 hidden-xs">
<span class="label label-warning">PROMOTII</span><span class="promo_1"> Promotii speciale de weekend!</span>
</div>
@endsection


master.blade.php:

<!-- Stored in resources/views/layouts/master.blade.php -->

<html>
<head>
<title>Sofa</title>
</head>
<body>

<div class="top">
<div class="container">
@include('top')
</div>
</div>

<div class="foo">

</div>
</body>
</html>

Answer

This is what you are doing: top extends master and master include top => cause never-end include => cause Memory error.

Solution: Remove

@extends('layouts.master')
@section('top')

And

@endsection

From your top.blade.php. That's it

Comments