Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raphael's avatar

Custom Error Page (not Custom HTTP Error Page)

[Laravel 5.5]

I would like to show a custom error page that has the same look as Laravel's HTTP errors (404, 500 etc.).

Controller:

$user = User::whereChangeEmailToken($token)->first();
if (! $user) {
    return view('errors.token');
}

Blade Template:

@extends('errors::layout')
@section('title', 'Unknown Token')
@section('message')
    Unknown Token
    <br>
    <br>
    <small>This link is invalid because we do not know this token.</small>
@stop

As you see, the blade template extends the errors layout in the same way as the http errors.

However, it gives me this error:

No hint path defined for [errors]. (View: /home/vagrant/code/project/resources/views/errors/token.blade.php)

My custom HTTP error pages in the same directory do work, though.

What am I doing wrong?

0 likes
3 replies
D9705996's avatar

The example http views all extend errors::illustrated-layout not errors::layout e.g.

@extends('errors::illustrated-layout')
...

The view is loaded by the framework from this function iirc

So you will need to pass in the required view data to prevent the error your getting and based on what you havdcshown this should work.

   return view('errors.token', [
        'errors' => new ViewErrorBag,
   ]);
raphael's avatar
@extends('errors::illustrated-layout')

seems to be as of version 5.7, but we are still using version 5.5.

Also, we tried to return a new ViewErrorBag as you mentioned, but that did not solve the issue.

We are still getting

No hint path defined for [errors]. (View: /home/vagrant/code/project/resources/views/errors/token.blade.php)
raphael's avatar
raphael
OP
Best Answer
Level 4

Okay, we got it working with @extends('errors.layout') instead of @extends('errors::layout').

We copied the Laravel errors layout blade into our view/errors folder.

2 likes

Please or to participate in this conversation.