2016-08-21 38 views
2

我想包含到我的master.blade.php中的一個top.blade.php文件,但我最終出現了這個錯誤:Laravel @include進主佈局結果如下:PHP致命錯誤:允許內存大小爲134217728字節耗盡

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

也許我做錯了什麼? 謝謝!

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> 
+0

看來你有內存泄漏的地方,它是你整個代碼?您可以嘗試將'@ stop'更改爲'@ endsection',因爲您在頂部視圖和本地視圖中使用了不同的結束標記。你也可以通過在代碼中執行'ini_set('memory_limit','256M');'來暫時設置更高的內存限制。 –

+0

這是造成主和頂之間的無限循環 – feareoc

回答

0

這是你正在做的事情:top擴展master和master include top =>導致永無止境include =>導致內存錯誤。

解決方案: 刪除

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

而且

@endsection 

從你top.blade.php。這就是它

+0

Jeeez,謝謝! –

相關問題