Closed fvsch closed 6 years ago
You could use @extends('master')
and leave the file on the templates root, but it's better to group layouts in it's own subfolder, thus @extends('layouts.master') is preferred. I'll add a note on the
readme.md` to better explain that the dot syntax means subfolder.
I got the Undefined property
and Fatal error: Method Illuminate\View\View::__toString() must not throw an exception
errors a few time too. The error message is indeed not very helpful. I haven't thought of catching the errors myself, I'll definitely look into that. Thank you very much for the suggestion!
I'll check out the kirby-twig
code too 😉
+1 for useful error messages
And Thanks @pedroborges for the nice plugin. Now I can get used to working with blade with my kirby projects and feel right at home when trying to get ahead with laravel.
@fvsch and @SirNovi, I finally got time to work on a fix for this issue and it turned out to be a simple one, yet hard to spot.
Please check out the develop branch of this repo for a fix. I'll tag a new version in the next few days.
So I used the
master.blade.php
anddefault.blade.php
examples from the README, but got an error catched by Whoops:And nothing in the stack trace, so Whoops showed my
index.php
, which was not very useful.With Whoops disabled, I get this error printed in the page:
Turned out I was using
@extends('layouts.master')
but had put mymaster.blade.php
at the root of the templates folder, rather than in a layouts subfolder. But with no relevant errors, that can be hard to figure out.In this specific case, both the basic error and the Whoops error handler page show the same unhelpful error. Here is a case where Whoops shows that unhelpful error but the basic error output is more helpful:
Basic output:
Whoops output:
For the record, I wrote https://github.com/fvsch/kirby-twig and since Twig was reporting meaningful errors but not adding them to a stack trace, I had to skip using Whoops and catch the errors myself to display an error page. Feel free to reuse my code if you think you want to do something similar.