加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – Laravel刀片性能

发布时间:2020-12-14 19:42:24 所属栏目:大数据 来源:网络整理
导读:我正在使用laravel blade文件,我想知道这种方法是否会减慢我的网站速度. 这是我的文件结构: show.blade.php文件: div class="table-sections" ... @include('elements/table',['name' = 'table1','blocks' = $blocks1]) ... @include('elements/table',['n
我正在使用laravel blade文件,我想知道这种方法是否会减慢我的网站速度.
这是我的文件结构:

show.blade.php文件:

<div class="table-sections">
   ...
   @include('elements/table',['name' => 'table1','blocks' => $blocks1])
   ...
   @include('elements/table',['name' => 'table2','blocks' => $blocks2])
   ...
</div>

table.blade.php文件:

...
@foreach($blocks as $block)
   ...
   @foreach($block['sections'] as $section)
      ...
      @foreach($section['rows'] as $row)
          ...
          @include('elements/row','row' => $row)
          ...
      @endforeach
      ...
   @endforeach
   ...
@endforeach
...

row.blade.php文件:

...
@foreach($row['attributes'] as $attribute)
   ...
   // Making the '<td>' elements with their respective attributes and html
   ...
@endforeach
...

我有很多嵌套的’foreach’块控制部分,所以我想知道在这种情况下是否最好不使用刀片(例如row.blade.php文件)

你有什么建议?

解决方法

太多的筑巢,在Laravel真的是一个不好的做法.
我们试图使代码干净,但这有时会导致性能折衷.
这就是为什么我最终决定创建一个小型磁带库,在生产中使刀片变平,从而将性能提高了x10倍.

从这里试试吧:
https://packagist.org/packages/te-cho/compile-blades

基本上,它所做的只是它需要刀片文件,它将包含和产量放在一个刀片文件中,而不包括也不产生.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读