Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Octane Issue request param #59

Open
lam0819 opened this issue Feb 3, 2025 · 7 comments
Open

Laravel Octane Issue request param #59

lam0819 opened this issue Feb 3, 2025 · 7 comments
Assignees
Labels
investigation Requires Investigation

Comments

@lam0819
Copy link

lam0819 commented Feb 3, 2025

When i am using laravel octane, I figure out that the param binding is missing now.
How can i solve it?

use Illuminate\Http\Request;
$api->group(['middleware' => ['api.auth']], function ($api) {

    $api->get('missions', [RewardMissionController::class, 'missions']);
    $api->get('missions/{slug}', [RewardMissionController::class, 'missionDetail']);
    $api->post('collectMission/{slug}', [RewardMissionController::class, 'collectMission']);

});

 public function missionDetail(Request $request ){
        $mission = RewardMission::where('slug', $request->slug)->first();
// ....
// $request->slug <---- is missing out , become null
}

However

use Illuminate\Http\Request;
 public function missionDetail(Request $request , $slug ){
 
// ....
// $slug <--- get correct param
// $request->slug <---- still missing out , become null
}

Also, I confirmed that if i not using dingo-api, it work perfectly.

@specialtactics
Copy link
Contributor

It may be an issue in dingo then @lam0819 , what if you just used $request->input('slug') instead?

@lam0819
Copy link
Author

lam0819 commented Feb 5, 2025

$request->input is null too.

i have tried reset , reinit the provider after requestreceived but no luck.

@specialtactics
Copy link
Contributor

@lam0819 One more, what if you use the global helper request()->input() instead?

@lam0819
Copy link
Author

lam0819 commented Feb 6, 2025

I try following

 $api->post('test/{slug}', function(Request $request , $slug){
        dd('Full Request:', [
            '$_SERVER[LARAVEL_OCTANE] -> s' => (isset($_SERVER['LARAVEL_OCTANE'])),
            '$request?->route()?->parameters() -> route' => $request?->route()?->parameters(),
            '$request?->input() -> input' => $request?->input(),
            'request()->input() -> input2' => request()->input(),
            '$slug -> slug_param' => $slug ?? '',
            '$request->slug -> request_slug' => $request->slug,
            'request()->slug -> request_slug2' => request()->slug,
        ]);

With Form Body
Image
Image

Without Form Body
Image

@specialtactics
Copy link
Contributor

Thanks, I will investigate what's going on here, I guess it's probably something to do with how bindings work with dingo in octane.

My plan is to swap out dingo with a more modern solution anyway, so that may be a better way to address it than to investigate what's going on within of that package.

I guess if you need a quick workaround, you can just then use the injected parameter to the controller?

@specialtactics specialtactics self-assigned this Feb 6, 2025
@specialtactics specialtactics added the investigation Requires Investigation label Feb 6, 2025
@lam0819
Copy link
Author

lam0819 commented Feb 6, 2025

injected back ? not sure how. or i can do it in middleware?

@specialtactics
Copy link
Contributor

Sorry perhaps I was not clear, in the very last screenshot you posted, the $slug is there, it comes from the controller parameter, so what I am saying is, you could perhaps get it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Requires Investigation
Projects
None yet
Development

No branches or pull requests

2 participants