Lumen-framework: [Routing] Call to a member function parameter() on array

Created on 5 Dec 2017  路  15Comments  路  Source: laravel/lumen-framework

$request->parameter;
// OR
$request->route('parameter');
// OR
$request->route()->getParameter('parameter');

Throws Call to a member function parameter() on array.

Bumping because all of the other issues are still alive :

https://github.com/laravel/lumen-framework/issues/291
https://github.com/laravel/lumen-framework/issues/650
https://github.com/laravel/lumen-framework/issues/484
https://github.com/laravel/lumen-framework/issues/119
...

Most helpful comment

Do

list($found, $routeInfo, $params) = $request->route() ?: [false, [], []];

Then

dd($params);

Is the expected thing on there?

All 15 comments

Do

list($found, $routeInfo, $params) = $request->route() ?: [false, [], []];

Then

dd($params);

Is the expected thing on there?

I proposed a fix for this but it was rejected: https://github.com/laravel/internals/issues/71

Suggested workaround: https://github.com/laravel/lumen-framework/issues/484#issuecomment-300170119

Alternatively you can modify the calling code to expect an array:

$param = $request->route()['parameter'] ?? null;

This issue still exists.

Confirming that this issue still exists.

Call to a member function parameter() on array in vendor/illuminate/http/Request.php:458

In my case, this was triggered by calling $request->json->all() from a Lumen Controller.

I just read from an issue that Taylor does not consider it as a bug and says Laravel and Lumen is not 100% compatible so it seems like this will not be fixed.

Just to confirm this same issue: "/management/stream/{parameter}" in the uri following lumen documentation. i get this error

1/1) FatalThrowableError Call to a member function parameter() on array
--
in Request.php line 501
at Request->route('parameter')in Request.php line 665

I was breaking things out in to microservice under the impression that lumen can be migrated in to laravel quite easily.

Thanks @JacksonIV

@abellion Anytime!

hi @abellion
this is already fixed, but when running on test is still same issue

Laravel Framework Lumen (5.7.6)
PHPUnit 7.4.4

testing.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function parameter() on array in ...

hi @abellion
this is already fixed, but when running on test is still same issue

Laravel Framework Lumen (5.7.6)
PHPUnit 7.4.4

testing.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function parameter() on array in ...

did u find any solutions?

hi @abellion
this is already fixed, but when running on test is still same issue
Laravel Framework Lumen (5.7.6)
PHPUnit 7.4.4

testing.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function parameter() on array in ...

did u find any solutions?

the same problem .
use $request->route()[2]['xxxxx'] ?? null can hack it

use $request->input()

dd($request->input())

then validate like

if (empty($request->input()))

and for a certain field

if (null !== $request->input('queja_estado'))

Any update on this? Awful to trick the framework that way...

already fixed here https://github.com/laravel/lumen-framework/pull/882
but not already release tag for it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jampack picture jampack  路  3Comments

GGNB picture GGNB  路  5Comments

maglor picture maglor  路  3Comments

soderluk picture soderluk  路  3Comments

jairobjunior picture jairobjunior  路  4Comments