Ad

Function Name Must Be A String In Laravel

- 1 answer

Laravel Framework 5.6.39 I'm getting this error:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Function name must be a string

Here is what I'm doing. In my App/RouteServiceProvider.php

public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    $this->mapMercuriusRoutes();
}

protected function mapMercuriusRoutes()
{
  Route::middleware(['web','auth','Mercurius'])
        ->namespace('\Launcher\Mercurius\Http\Controllers')
        ->group(base_path('routes/mercurius.php'));
}

Then my route file mercurius.php:

// Mercurius home
Route::get('/messages', ['as' => 'home', 'uses' => '[email protected]']);
// User Profile
Route::get('/profile/refresh', '[email protected]');
Route::get('/profile/notifications', '[email protected]');
Route::post('/profile', '[email protected]');

When I go to localhost:8000/messages as listed in the Mercurius routes file I get the error. Any idea what I'm doing wrong?

EDIT: INITIAL ERRORS:

$response = method_exists($pipe, $this->method)
                                ? $pipe->{$this->method}(...$parameters)
                                : $pipe(...$parameters);

The $pipe(...$parameters); is the highlighted one.

Symfony\Component\Debug\Exception\FatalThrowableError 
…/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php152

Illuminate\Pipeline\Pipeline Illuminate\Pipeline\{closure}
…/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php53

Illuminate\Routing\Pipeline Illuminate\Routing\{closure}
…/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php41
Ad

Answer

Make sure that Mercurius middleware is defined and registered correctly in the Route Service Provider.

Ad
source: stackoverflow.com
Ad