Framework: Exception output of missing function in controller is wrong

Created on 29 Jan 2019  Â·  6Comments  Â·  Source: laravel/framework

  • Laravel Version: 5.7.22
  • PHP Version: 7.2.4
  • Database Driver & Version: -

Description:

When you add a route to a controller function that does not exist, laravel throws a ReflectionException instead of a BadMethodCallException. The exception says that the function () does not exist.

bildschirmfoto 2019-01-29 um 11 23 19

Steps To Reproduce:

  1. Edit your web.php file like this (does not happen when you pass the controller and function as string)
Route::get('/test', [TestController::class, 'index']);
  1. Create the TestController but don't create function index
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
{
    //
}
  1. Visit the new route

Expected behaviour would be that laravel tells which function does not exist.

All 6 comments

Hmm, I can see why this is a problem indeed although I wouldn't necessarily label this as a bug but rather an enhancement. Welcoming PRs which might improve this error message.

Is it even the good syntax? I mean even if you put a name of existing method it wouldn't work.

The syntax is correct. I think this is possible since 5.6 or 5.7, not sure.

Am 30.01.2019 um 17:25 schrieb Inani El Houssain notifications@github.com:

Is it even the good syntax? I mean even if you put a name of existing method it wouldn't work.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

may be something related to the version of PHP 7.1.20

A PR was merged that should address this: https://github.com/laravel/framework/pull/28397

Thanks @570studio

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SachinAgarwal1337 picture SachinAgarwal1337  Â·  3Comments

Anahkiasen picture Anahkiasen  Â·  3Comments

fideloper picture fideloper  Â·  3Comments

iivanov2 picture iivanov2  Â·  3Comments

YannPl picture YannPl  Â·  3Comments