Skip to content

[Laravel] Can not access request data #136

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

Closed
tobiasdierich opened this issue Sep 3, 2018 · 2 comments · Fixed by #137
Closed

[Laravel] Can not access request data #136

tobiasdierich opened this issue Sep 3, 2018 · 2 comments · Fixed by #137

Comments

@tobiasdierich
Copy link
Contributor

tobiasdierich commented Sep 3, 2018

Description

Access the request data using $request->get('data') returns nothing, however using $request->data works.

Setup:

Laravel app running inside the phppm/nginx container

php-pm: v1.0.4
php-pm-httpkernel: v1.0.4
Laravel: v5.6

Steps to reproduce:

  1. Clone my example repo: git clone https://github.com/tobiasdierich/php-pm-example (The only important bit is here: https://github.com/tobiasdierich/php-pm-example/blob/master/routes/api.php`)
  2. Run composer: composer install --no-dev
  3. Start php-pm: docker run -v `pwd`:/var/www -p 8080:80 phppm/nginx --bootstrap=laravel --static-directory=public/
  4. Make a post request to /api/foo with POST data:
{
   "foo": "bar"
}
  1. Make the same request to /api/bar

Result:

The first request to /api/foo returns nothing, the second however returns bar.

Expected behaviour:

Both requests should return bar.

@tobiasdierich
Copy link
Contributor Author

I did some tinkering and figured out that this could easily be fixed by changing the way how the laravel request instance is created.

Instead of directly creating a new Illuminate\Http\Request instance, you could create a Symfony request first and convert it to an Illuminate request by using Illuminate\Http\Request::createFromBase($symfonyRequest). This is the way the laravel kernel does it as well.

I'd be happy to contribute a PR to fix this.

@andig
Copy link
Contributor

andig commented Sep 5, 2018 via email

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

Successfully merging a pull request may close this issue.

2 participants