laravel5-jsonapi icon indicating copy to clipboard operation
laravel5-jsonapi copied to clipboard

Lumen installation throws action() exception

Open OskarD opened this issue 8 years ago • 13 comments

I am trying to implement this with a Lumen application, and I get the following exception:

"exception": {
      "type": "FatalThrowableError",
      "file": "JsonApiTrait.php",
      "line": 74,
      "message": "Fatal error: Call to undefined function NilPortugues\Laravel5\JsonApi\Controller\action()"
    }

Am I missing something or are there compatibility problems?

JsonApiTrait uses the action() helper, which is unavailable with Lumen.

OskarD avatar Mar 02 '16 08:03 OskarD

I think something went wrong in my set-up. I re-did everything and didn't get this error anymore.

I am getting this, however: "status": 400, "title": "Bad Request", "detail": "Request could not be served."

Not much to go by here... Any tips?

OskarD avatar Mar 02 '16 09:03 OskarD

Hmm go to the NilPortugues\Laravel5\JsonApi\Controller\JsonApiTrait and go to the exception bit matching your action and do a print_r or a $e->getMessage.

You'll get the info there.

I've been already requested to add a dev flag to let these errors go up, instead of catching them. But haven't had time to add the feature yet.

nilportugues avatar Mar 02 '16 09:03 nilportugues

I am getting the first error again... It's because JsonApiTrait uses the action() helper on line 74. Is it supposed to do this?

I change it to this and I get the second error instead (Which also appears on the show-page): $uri = route('myresource.index'); // action($controllerAction, []);

Edit: It turns out the second error is caused by this: Undefined index: App\Party\Property\Property. It's probably specific to my other code, so I will figure it out myself. But the above problem still remains!

OskarD avatar Mar 02 '16 10:03 OskarD

@OskarD did you solve this? I'm actually curious what was making it happen... so maybe I can add a defensive check.

nilportugues avatar Mar 02 '16 13:03 nilportugues

@nilportugues no, it's still happening.

Why is it calling the action() helper-function? Is it supposed to happen? It isn't featured in Lumen

OskarD avatar Mar 02 '16 13:03 OskarD

@nilportugues the action() function is not available in Lumen, it shouldn't be called in JsonApiTrait (Line 74) if using Lumen, should it?

OskarD avatar Mar 08 '16 13:03 OskarD

https://github.com/nilportugues/laravel5-jsonapi/releases/tag/2.1.11

Try updating your composer dependency to use release 2.1.11.

nilportugues avatar Mar 08 '16 15:03 nilportugues

Thank you @nilportugues for helping out, but I'm afraid it isn't enough

$absolute in the action arguments needs to be defaulted to true for the code to run without a Missing argument 3 error, and after fixing that I get this error instead: Fatal error: Call to undefined method Laravel\Lumen\Routing\UrlGenerator::action()

I don't think Lumen offers the action functionality at all :/

OskarD avatar Mar 08 '16 15:03 OskarD

I'll have to hack it better. Not at home right now. Sorry is taking so long.

nilportugues avatar Mar 08 '16 16:03 nilportugues

It's OK, I am very glad you are willing to help :)

OskarD avatar Mar 09 '16 08:03 OskarD

@nilportugues have you had the chance to take a look at this yet?

OskarD avatar Mar 14 '16 14:03 OskarD

Starting tomorrow evening I'll be capable to look into it. Been quite busy lately

nilportugues avatar Mar 14 '16 14:03 nilportugues

Any news @nilportugues?

OskarD avatar Mar 29 '16 07:03 OskarD