0

I'm working with Laravel 5.8 and I'm trying to sent parameters from my controller to a php file that is not a view. I've tried this way: return redirect('my-route/?my-parameter='.'value'); But I want to send it with POST method, how can I do that ?

  • What is the other `.php` file, controller, model, or something else? Not sure what you're asking here.. – zlatan Nov 30 '19 at 20:43
  • It seems OP wants to call a URL (outside their Laravel app) with the same arguments the controller received. – Arcesilas Nov 30 '19 at 21:04
  • From what I understand, you are trying to make a request to an external url. Personally, I will use guzzle to achieve that, you can check more here https://stackoverflow.com/questions/22355828/doing-http-requests-from-laravel-to-an-external-api, it might be helpful if you already know a bit about curl. – Nikolay Nov 30 '19 at 21:09
  • I want to send parameters to a file that exist in my public folder, i want him to receive those parameters just like the views do. – soukaina kenitra Nov 30 '19 at 21:47

1 Answers1

0

If you are sending a request to another php application (or any application really) then I would also second @Nikolay and check out Guzzle. Or, another option would be to check out Requests I've used both and both I think would get you what you're looking for.

Either option works great when communicating server-to-server (not an ajax call to an internal controller method).

The php file in your public folder will need to be able to check for such request(s). Without knowing what that file looks like, somewhere/how you'll need to check if there are query parameters.

Hope this helps!

Damon
  • 4,151
  • 13
  • 52
  • 108