【问题标题】:Blade Layout in Laravel is not workingLaravel 中的刀片布局不起作用
【发布时间】:2014-08-14 09:18:51
【问题描述】:

我在app/layout/ 文件夹中有刀片模板,即default.blade.php

<!doctype html>
<html>
    <head>
        @include('includes.head')
    </head>
    <body>
        <div class="container">
            <header class="row">
                @include('includes.header')
            </header>

            <div id="main" class="row">
                @yield('content')
            </div>

            <footer class="row">
                @include('includes.footer')
            </footer>
        </div>
    </body>
</html>

文件夹结构:

app/views/layout/default.blade.php
app/views/includes/footer.blade.php
app/views/includes/head.blade.php
app/views/includes/header.blade.php

我的控制器是blade.php

<?php
    class Blade extends BaseController
    {
        public function layout()
        {
            return View::make('layout.default');
        }
    }
?>

Routes.php

Route::get('blade','Blade@layout');

我将控制器指向浏览器,例如:

http://localhost/laravel/public/blade

显示错误:

Call to undefined method Illuminate\Support\Facades\Blade::getAfterFilters() 

我该如何解决。请帮帮我。

【问题讨论】:

  • 根命名空间中的 class Blade 在 Laravel 中为 Blade 别名保留。将您的控制器名称更改为更具表现力的名称。
  • @大卫。运行良好,谢谢

标签: laravel blade


【解决方案1】:

你不能命名你的控制器 BLADE,Blade 是 Laravel 中模板引擎的外观,重命名你的控制器,然后是 Blade。

你可以在你的 config\app.php 中的关键别名中找到所有 Laravel 内部 Facades

【讨论】:

  • Facades 是静态类,可以让 laravel 代码看起来更好,更多信息请看here
  • Laravel 其他框架有什么优势?
猜你喜欢
  • 2019-01-31
  • 2013-02-25
  • 2017-01-27
  • 2019-01-12
  • 2014-11-15
  • 2018-05-16
  • 1970-01-01
  • 2016-03-11
  • 2013-06-04
相关资源
最近更新 更多